パッケージは、現在の時刻を取得し(時間帯)

新規フォルダの例以下のSRC:utilsの

再-utilsのファイルの新しいJSの例:dateFormat.js

コンテンツ:

/ **
* @part {[NUM]}需要返回的天数0当前-1昨天
* @return {[日付]} YYYY-MM-DD
* /
dateChange constの輸出=パート=> {
ましょう今日=新しいDate() ;
せtargetday_milliseconds = today.getTime()+ 1000年* 60 * 60 * 24 *部分、
today.setTime(targetday_milliseconds)。
)(tYear = today.getFullYearてみましょう。
tMonth = today.getMonth()しましょう。
)(tDate = today.getDateてみましょう。
tMonth = doHandleMonth(tMonth + 1)。
tDate = doHandleMonth(tDate)。
リターンtYear + " - " + tMonth + " - " + tDate。

関数doHandleMonth(月){
M =月を聞かせて、
IF(month.toString()長さ== 1){
  M = "0" +月;
}。
メートルを返します。
}
}


/ **
*时间戳转YYYY-MM-DD
* @param {[タイプ]}
* @return {[タイプ]}
* /
エクスポートCONST formatUnixtimestamp = unixtimestamp => {
VAR unixtimestamp =新しい日付(unixtimestamp * 1000)。
VAR年= 1900 + unixtimestamp.getYear();
VAR月= "0" +(unixtimestamp.getMonth()+ 1);
VAR日= "0" + unixtimestamp.getDate();
VaRの時間= "0" + unixtimestamp.getHours();
VAR分= "0" + unixtimestamp.getMinutes();
VaRの第二= "0" + unixtimestamp.getSeconds()。
戻り年+ " - " + month.substring(month.length-2、month.length)+ " - " + date.substring(date.length-2、date.length)
+ "" + hour.substring(時間。長さ-2、時間。
+ minute.substring(minute.length-2、minute.length)+ ":"
+ second.substring(second.length-2、second.length)。
}

-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ----------

ページの呼び出し: '@ / utilsの/ dateFormat.js' からインポート{} dateChange

メソッド呼び出し:this.value1 = [dateChange(0)+ '00:00:00' 、dateChange(0)+ '23:59:59' ]

 

おすすめ

転載: www.cnblogs.com/PoisonousMushrooms/p/11936045.html