f.Date().format()
f.Date(DateString, FormatString).format(formatToken)
설명
f.Date()로 생성된 Date객체를 포맷에 맞춰 반환한다.
파라미터
formatToken
필수
String
Tokens 항목만 사용가능
반환받을 날짜 형식을 지정합니다.
Tokens
YYYY
4 digit year
2014
YY
2 digit year
14
Y
Year with any number of digits and sign
-25
Q
Quarter of year. Sets month to first month in quarter.
1..4
M MM
Month number
1..12
MMM MMMM
Month name in locale set by moment.locale()
Jan..December
D DD
Day of month
1..31
Do
Day of month with ordinal
1st..31st
DDD DDDD
Day of year
1..365
ddd dddd
Day name in locale set by moment.locale()
Mon...Sunday
H HH
Hours (24 hour time)
0..23
h hh
Hours (12 hour time used with a A.)
1..12
k kk
Hours (24 hour time from 1 to 24)
1..24
a A
Post or ante meridiem (Note the one character a p are also considered valid)
am pm
m mm
Minutes
0..59
Z ZZ
Time zone
+09:00
S SS SSS ... SSSSSSSSS
Fractional seconds
0..999999999
s ss
Offset from UTC as +-HH:mm, +-HHmm, or Z
+12:00
예시
//f.Date().date == Thu Oct 22 2020 15:10:29 GMT+0900 (대한민국 표준시)
//f.Date() 는 현재시간을 가져오게 됩니다.
f.Date().format('YYYY') //2020
f.Date().format('MM') // 10
f.Date().format('DD') // 22
f.Date().format('YYYYMM') //202010
f.Date().format('MMDD') //1022
f.Date().format('YYYY-MM-DD') //2020-10-22
f.Date().format('YYYY.MM.DD') //2020.10.22
f.Date().format('YYYY/MM/DD') //2020/10/22
f.Date().format('MM|DD') // 10|22Last updated
Was this helpful?