Step 1: Add the intl package.
Step 2: Get the date that you want to format.
Step 3: Use the named constructor and then call the format() method and then provide the date.
Custom DateFormat
DateFormat('yyyy-MM-dd hh:mm')
The following characters are available in explicit patterns:
Symbol Meaning Presentation Example
------ ------- ------------ -------
G era designator (Text) AD
y year (Number) 1996
M month in year (Text & Number) July & 07
L standalone month (Text & Number) July & 07
d day in month (Number) 10
c standalone day (Number) 10
h hour in am/pm (1~12) (Number) 12
H hour in day (0~23) (Number) 0
m minute in hour (Number) 30
s second in minute (Number) 55
S fractional second (Number) 978
E day of week (Text) Tuesday
D day in year (Number) 189
a am/pm marker (Text) PM
k hour in day (1~24) (Number) 24
K hour in am/pm (0~11) (Number) 0
Q quarter (Text) Q3
' escape for text (Delimiter) 'Date='
'' single quote (Literal) 'o''clock'
沒有留言:
發佈留言