久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何將 Unix 時(shí)間戳轉(zhuǎn)換為 Jalali/Shamsi/Persian 格式

How do you convert a Unix timestamp to Jalali/Shamsi/Persian format?(如何將 Unix 時(shí)間戳轉(zhuǎn)換為 Jalali/Shamsi/Persian 格式?)
本文介紹了如何將 Unix 時(shí)間戳轉(zhuǎn)換為 Jalali/Shamsi/Persian 格式?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在開發(fā)一個(gè)網(wǎng)絡(luò)應(yīng)用程序,并且我有一個(gè) unix 時(shí)間戳.我需要使用 jQuery 選擇器將 unix 日期格式轉(zhuǎn)換為 Jalali/Persian/Shamsi 日歷,然后使用 javascript 庫進(jìn)行轉(zhuǎn)換.
下面的代碼將 Unix-Date 轉(zhuǎn)換為 Jalali-Date:

I'm developing a web App and I have a unix timeStamp. I need to convert a unix date format to Jalali/Persian/Shamsi Calendar by using jQuery selectors and then convert it by using javascript library.
Something Like below code to convert Unix-Date to Jalali-Date:

<html>
  <head>
  <meta charset="utf-8">
  </head>

  <body>
  <div class="Unix-Date">1494259627</div> <!-- Unix equal of 1396/2/18 -->
  <div class="Jalali-Date"></div>

  <script src="jquery.js"></script>
  <script src="external-library.js"></script>
  <script>
  $(document).ready(function() {
  var UnixValue;
  var JalaliValue;
  UnixValue = $(".Unix-Date").html();
  JalaliValue = new JalaliExternalFunction(UnixValue);
  $(".Jalali-Date").text(JalaliValue);
  });
  </script>
  </body>
</html>

我搜索但沒有找到任何好的圖書館.您知道用于轉(zhuǎn)換(或從 unix 時(shí)間戳創(chuàng)建 Jalali 格式的日期)的可靠且良好的庫嗎?我不需要你的實(shí)現(xiàn)或算法,因?yàn)檫@個(gè)問題太 bug 并且有很多規(guī)則,我需要一個(gè)可靠的解決方案.

I searched but didn't found any good library. Do you know a reliable and good library for converting (or creating dates in Jalali format from a unix timeStamp). I don't need your implementation or an algorithm, cause this issue is too buggy and has a lot of rules, I need a reliable solution.

謝謝

推薦答案

我建議使用 moment.js (https://momentjs.com/),這是一個(gè)可靠的 JavaScript 時(shí)間庫,允許您在 JavaScript 中格式化您的時(shí)間戳.下面是一個(gè)示例,說明如何解析時(shí)間戳并將其格式化為您想要使用的任何格式.

I would suggest using moment.js (https://momentjs.com/) which is reliable JavaScript Time library that allows you to format your timestamp in JavaScript. Below is an example of how you can parse a timestamp and format it to whatever you want using it.

//formatting Unix timestamp.
var date = moment.unix(value).format("MM/DD/YYYY");

您還標(biāo)記了可以通過使用來完成的本地化;

You also tagged localization which can be done by using;

 var localeDate = moment(date).locale("LT");

更多示例可以在該網(wǎng)站上找到.

More examples can be found on there website.

這與 https://www.npmjs.com/package/jalali-date 會(huì)給你你的 jalali 日期.

This in conjunction with https://www.npmjs.com/package/jalali-date will get you your jalali date.

這里還有一個(gè)波斯語的 moment.js 擴(kuò)展 https://www.npmjs.com/package/moment-jalaali(從時(shí)刻到 Jalali)

There is a moment.js extension for Persian here also https://www.npmjs.com/package/moment-jalaali (From moment to Jalali)

另一個(gè) Jalali 轉(zhuǎn)換庫 https://www.npmjs.com/package/jalaali-js(致賈萊)

Another Jalali conversion library https://www.npmjs.com/package/jalaali-js (To Jalai)

使用從 Unix 時(shí)間戳轉(zhuǎn)換的 moment.js Jalali 的示例小提琴 https://jsfiddle.net/uw82ozpd/9/

An example fiddle using moment.js Jalali conversion from Unix Timestamp https://jsfiddle.net/uw82ozpd/9/

帶注釋的相關(guān)代碼段:

var UnixValue;
var JalaliValue;

$(document).ready(function() {

//get the Unix Date from HTML
var UnixValue = $(".Unix-Date").html();

//Get a moment timestamp in the format simmilar to our next conversion
var date = moment.unix(UnixValue).format("MM/DD/YY");

//Convert from normal moment to our jalali moment exstension using j's as below
var JalaliValue = moment(date).format('jYYYY/jM/jD');

$(".Jalali-Date").text(JalaliValue);

});

這篇關(guān)于如何將 Unix 時(shí)間戳轉(zhuǎn)換為 Jalali/Shamsi/Persian 格式?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進(jìn)程中創(chuàng)建子窗口時(shí)如何修復(fù) BrowserWindow 不是構(gòu)造函數(shù)錯(cuò)誤) - IT屋-程序員軟件開發(fā)技術(shù)
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應(yīng)用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個(gè) loadURL 上執(zhí)行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內(nèi)使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲(chǔ)?)
How to access camera/webcamera inside electron app?(如何在電子應(yīng)用程序中訪問相機(jī)/網(wǎng)絡(luò)攝像頭?)
主站蜘蛛池模板: 一区二区三区视频在线免费观看 | 久久精品视频9 | 精品在线观看入口 | 欧美视频在线播放 | 国产午夜在线 | 色视频在线免费观看 | 激情一区二区三区 | 亚洲福利一区 | 精品少妇一区二区三区日产乱码 | av网址在线播放 | 久久草在线视频 | 天天干天天色 | 国产欧美日韩综合精品一 | 日本一区二区影视 | 国产精品99久久久久 | 日本高清视频在线播放 | 国产精品成人av | 久草福利 | 国产精品久久久久久久久久久久 | 亚洲一区av在线 | 国产精品成人一区二区 | 巨大荫蒂视频欧美另类大 | 欧美精品成人 | 色狠狠一区 | 精品一区二区电影 | 日本不卡高字幕在线2019 | 91综合网 | 日韩视频三区 | 在线观看成人小视频 | 亚洲精品福利在线 | 国产一区二区三区四区五区3d | 久久久精品视频一区二区三区 | 自拍视频一区二区三区 | 天天干夜夜操 | 国产在线观看一区二区 | 国产乱码精品一区二区三区中文 | 久久性| 亚洲v日韩v综合v精品v | 欧美日韩综合一区 | 日韩欧美在线精品 | 日韩欧美一级精品久久 |