Skip to content

Instantly share code, notes, and snippets.

@wewindy
Created August 2, 2021 06:49
Show Gist options
  • Select an option

  • Save wewindy/9f50f6722dc62ea82e5d9ce4b94fec06 to your computer and use it in GitHub Desktop.

Select an option

Save wewindy/9f50f6722dc62ea82e5d9ce4b94fec06 to your computer and use it in GitHub Desktop.
A simple custom moment format demo
import moment from 'moment'
moment(`2010/1/1 19:20:59.990`, 'YYYY/M/D HH:mm:ss.SSS')
// 解析到的月份是0开头的
@wewindy
Copy link
Author

wewindy commented Aug 2, 2021

年份字母是 YYYYY 代表解析4个数字的年份
月份字母是 MM 代表解析1个数字,MM 代表解析两个数字的月份
以此类推,查文档即可。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment