[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
Token Output
Month M 1 2 ... 11 12
MM 01 02 ... 11 12
MMM Jan Feb ... Nov Dec
MMMM January February ... November December
Day of Month D 1 2 ... 30 31
Do 1st 2nd ... 30th 31st
DD 01 02 ... 30 31
Day of Week d 0 1 ... 5 6
ddd Sun Mon ... Fri Sat
dddd Sunday Monday ... Friday Saturday
Year YY 70 71 ... 29 30
YYYY 1970 1971 ... 2029 2030
AM/PM A AM PM
a am pm
Hour H 0 1 ... 22 23
HH 00 01 ... 22 23
h 1 2 ... 11 12
hh 01 02 ... 11 12
Minute m 0 1 ... 58 59
mm 00 01 ... 58 59
Second s 0 1 ... 58 59
ss 00 01 ... 58 59
Fractional Second S 0 1 ... 8 9
SS 0 1 ... 98 99
SSS 0 1 ... 998 999
Timezone ZZ -0700 -0600 ... +0600 +0700

【每日一包0018】fecha的更多相关文章

  1. 【每日一包0005】arr-flatten

    github地址:https://github.com/ABCDdouyae... arr-flatten 将多维数组展开成一维数组 文档地址:https://www.npmjs.com/packag ...

  2. 【每日一包0011】pad

    [github地址:https://github.com/ABCDdouyae...] pad 给字符串的左右加padding,也可以用于删减字符串两端 用法:pad(str, length, opt ...

  3. 【每日一包0015】gradient-string

    [github地址:https://github.com/ABCDdouyae...] gradient-string 用于在终端打印出好看的渐变文字 普通用法 console.log(gradien ...

  4. 【每日一包0001】is-sorted

    github地址:https://github.com/ABCDdouyae... is-sorted 用于判断数组是否被排序了 文档地址:https://www.npmjs.com/package/ ...

  5. 【每日一包0003】kind-of

    github地址:https://github.com/ABCDdouyae... kind-of 判断数据类型用法:kind-of(date)返回:string 数据类型 January undef ...

  6. 【每日一包0008】arr-diff

    [github地址:https://github.com/ABCDdouyae...] arr-diff 多个数组比较,过滤出第一个数组独有的内容 用法:arr-diff(arr1, arr2, ar ...

  7. 【每日一包0009】group-array

    [github地址:https://github.com/ABCDdouyae...] group-array 对数组里面的多项按照指定的key进行整合 用法:group-array(arr, key ...

  8. 【每日一包0012】to-camel-case,to-no-case,to-space-case

    github地址:https://github.com/ABCDdouyaer/a_pack_per_day_NO.1 to-camel-case 将被其他符号分割的字符串转换为驼峰形式的字符串 用法 ...

  9. 【每日一包0002】array-first

    github地址:https://github.com/ABCDdouyae... array-first 获取数组的第一项或者前几项 文档地址:https://www.npmjs.com/packa ...

随机推荐

  1. ZOJ-1610 Count the Colors(线段树染色,求染色段)

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1610 https://vjudge.net/contest/318019# ...

  2. space sniffer

    space sniffer 一款检测本地磁盘文件占用情况的工具,高效,快速.

  3. Automatic Setup of a Humanoid

    The humanoid animation option in Unity 4 makes it possible to retarget the same animations to differ ...

  4. 29)PHP,自动加载类

    (1)作用: 类的自动加载是指,在外面的页面中,并不需要去“引入”(包含)类文件,但是程序会在需要一个类的时候就自动去“动态加载”该类. (2)什么叫做“需要一个类”?通常是这样的情况: 1,创建一个 ...

  5. crm项目-业务实现

    ###############  crm业务    ############### """ 校区管理,部门管理,课程管理, 这三个都比较简单 1,只需要展示校区名称,这是 ...

  6. Linux的iptables菜鸟初学

    什么是iptables? iptables是linux下的命令行工具,操控的是linux的防火墙,这个防火墙叫netfilter.通俗的说应该是用户通过iptables把安全设定设置给netfilte ...

  7. VSTO外接程序项目只用1个文件实现Ribbon CustomUI和CustomTaskpane定制【C#版】

    VSTO中的自定义功能区和自定义任务窗格需要用到各种命名空间.添加所需文件,才能实现.后来我发现可以把所有代码都写在ThisAddin.cs这个默认文件中. 大家可以在Visual Studio中创建 ...

  8. gpio 的配置

    1.时钟使能 B引脚RCC时钟脉冲启动.|(或)表示只要第三个为1就行. 也可以写为RCC_APB2ENR  | = 0X0008; 2.配置GPIO的输出模式以及速度 3 . 如果是 0号引脚:GP ...

  9. ospf实验二

    R1,R2,R3为17.1.1.0网段 1. R4先做rip #rip 1 #version 2 #undo sum.. #netwokr 14.0.0.0 实验第四条 标记tag 100 在R4上做 ...

  10. js引入的几种简单写法

    [方法一]   <script>     function loadScript() {        var script = document.createElement(" ...