【逐日一包0018】fecha

[github地点:https://github.com/ABCDdouyae…]

fecha

比moment.js越发轻量级的时候剖析和格式化包

format

用法:format(<Date Object|String|timestamp>, <String Format>)

返回:string

const fecha = require('fecha');
fecha.format(new Date('2018','3','23','12','0','0'), 'YYYY-MM-DD HH-mm-ss dddd');
//2018-04-23 12-00-00 Monday
fecha.format(12312312, 'YYYY/MM/DD HH-mm-ss dddd');
//1970/01/01 11-25-12 Thursday
parse

用法:format(String, <String Format>)

返回:<Date Object>

fecha.parse('February 3rd, 2014', 'MMMM Do, YYYY');
 //  2014-02-02T16:00:00.000Z
fecha.parse('10-12-10 14:11:12', 'YY-MM-DD HH:mm:ss');
 //2010-12-10T06:11:12.000Z
TokenOutput
MonthM1 2 … 11 12
MM01 02 … 11 12
MMMJan Feb … Nov Dec
MMMMJanuary February … November December
Day of MonthD1 2 … 30 31
Do1st 2nd … 30th 31st
DD01 02 … 30 31
Day of Weekd0 1 … 5 6
dddSun Mon … Fri Sat
ddddSunday Monday … Friday Saturday
YearYY70 71 … 29 30
YYYY1970 1971 … 2029 2030
AM/PMAAM PM
aam pm
HourH0 1 … 22 23
HH00 01 … 22 23
h1 2 … 11 12
hh01 02 … 11 12
Minutem0 1 … 58 59
mm00 01 … 58 59
Seconds0 1 … 58 59
ss00 01 … 58 59
Fractional SecondS0 1 … 8 9
SS0 1 … 98 99
SSS0 1 … 998 999
TimezoneZZ -0700 -0600 … +0600 +0700
    原文作者:王炜
    原文地址: https://segmentfault.com/a/1190000017140339
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞