Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moment.js #13

Open
HAAAAADION opened this issue Oct 27, 2017 · 0 comments
Open

moment.js #13

HAAAAADION opened this issue Oct 27, 2017 · 0 comments

Comments

@HAAAAADION
Copy link
Owner

HAAAAADION commented Oct 27, 2017

format()参数

标识 输出
M 1 2 ... 11 12
Mo 1st 2nd ... 11th 12th
MM 01 02 ... 11 12
MMM Jan Feb ... Nov Dec
MMMM January February ... November December
Q 1 2 3 4
天数(月) D 1 2 ... 30 31
Do 1st 2nd ... 30th 31st
DD 01 02 ... 30 31
天数(年) DDD 1 2 ... 364 365
DDDo 1st 2nd ... 364th 365th
DDDD 001 002 ... 364 365
Day of Week d 0 1 ... 5 6
do 0th 1st ... 5th 6th
dd Su Mo ... Fr Sa
ddd Sun Mon ... Fri Sat
dddd Sunday Monday ... Friday Saturday
星期(本地) e 0 1 ... 5 6
星期(ISO) E 1 2 ... 6 7
周数 w 1 2 ... 52 53
wo 1st 2nd ... 52nd 53rd
ww 01 02 ... 52 53
周数(ISO) W 1 2 ... 52 53
Wo 1st 2nd ... 52nd 53rd
WW 01 02 ... 52 53
YY 70 71 ... 29 30
YYYY 1970 1971 ... 2029 2030
周、年 gg 70 71 ... 29 30
gggg 1970 1971 ... 2029 2030
周、年(ISO) GG 70 71 ... 29 30
GGGG 1970 1971 ... 2029 2030
AM/PM A AM PM
a am pm
H 0 1 ... 22 23(24小时)
HH 00 01 ... 22 23(24小时)
h 1 2 ... 11 12(12小时)
hh 01 02 ... 11 12(12小时)
m 0 1 ... 58 59
mm 00 01 ... 58 59
s 0 1 ... 58 59
ss 00 01 ... 58 59
分数秒 S 0 1 ... 8 9
SS 00 01 ... 98 99
SSS 000 001 ... 998 999
SSSS ... SSSSSSSSS 000[0..] 001[0..] ... 998[0..] 999[0..]
时区 z or zz EST CST ... MST PST 注意: 自 1.6.0版本后,z/zz格式标识不再支持 查看详细
Z -07:00 -06:00 ... +06:00 +07:00
ZZ -0700 -0600 ... +0600 +0700
UNIX时间戳(秒级) X 1360013296
NIX时间戳(毫秒级) x 1360013296123

本地化格式

因为不同地区的首选格式不同,这里还提供了一些特殊标识时用于moment的本地格式化。在这些格式中,格式标识大小写作用相同:

时间 LT 8:30 PM
时间和秒 LTS 8:30:25 PM
数字月、日、年 L 09/04/1986
  l 9/4/1986
月名、日、年 LL September 4 1986
  ll Sep 4 1986
月名、日、年、时间 LLL September 4 1986 8:30 PM
  lll Sep 4 1986 8:30 PM
月名、日、星期、年、时间/b> LLLL Thursday, September 4 1986 8:30 PM
  llll Thu, Sep 4 1986 8:30 PM

可能会出现时区不准确的情况,比如转换成国际时间后会+8小时,可以在转换前调用utc():

moment(time).utc().format()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant