项目作者: porsager

项目描述 :
Small template string based date formatter for the browser and Node.js.
高级语言: JavaScript
项目地址: git://github.com/porsager/datie.git
创建时间: 2020-05-13T08:44:17Z
项目社区:https://github.com/porsager/datie

开源协议:

下载


🗓 Datie

Small template string based date formatter for the browser and Node.js.

Follows https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table with the inclusion of o suffix to enable eg. 1st, 2nd etc.

Usage

Datie takes the format as a tagged template function and then returns a function which accepts the date or a new Date compatible string.

  1. import datie from 'datie'
  2. const string = "2020-05-13T08:34:30.911Z"
  3. const date = new Date(string)
  4. datie`d/M-y hh:mm`(string) // 13/5-2020 08:34
  5. // or
  6. datie`d/M-y hh:mm`(date) // 13/5-2020 08:34