時間戳轉化為年月日時分秒

2021-09-01 02:25:33 字數 1048 閱讀 2125

/**

* 資料轉化

* @param n

* @returns

*/function

formatnumber

(n)/**

* 時間戳轉化為年 月 日 時 分 秒

* @param number 傳入時間戳

* @param format 返回格式,支援自定義,但引數必須與formatearr裡保持一致

* @returns

*/export

const

formattime

=(number, format)

=>

returnarr.

push

(date.

getfullyear()

);returnarr.

push

(formatnumber

(date.

getmonth()

+1))

; returnarr.

push

(formatnumber

(date.

getdate()

)); returnarr.

push

(formatnumber

(date.

gethours()

)); returnarr.

push

(formatnumber

(date.

getminutes()

)); returnarr.

push

(formatnumber

(date.

getseconds()

));for

(var i in returnarr)

return format;

}

例子:

時間戳轉化為年 月 日 時 分 秒

this.$formattime('1477808630000 ', 'y-m-d h:m:s')

獲取年月日時分秒

calendar ca calendar.getinstance int year ca.get calendar.year 獲取年份 2016 system.out.println year int month ca.get calendar.month 獲取月份 10 1 system.out....

python年月日時分秒

通過datetime函式獲取 import datetime 取當前時間 print datetime.datetime.now 取年 print datetime.datetime.now year 取月 print datetime.datetime.now month 取日 print dat...

取時間的年月日時分秒

c 中 取時間的年月日時分秒 1 時間格式轉換 system.datetime currenttime new system.datetime 1.1 取當前年月日時分秒 currenttime system.datetime.now 1.2 取當前年 int 年 currenttime.year ...