formatDate

formatDate ( string format , long timestamp , string _locale , boolean _returnObject ) : string

Return a date formatted from a timestamp in milliseconds.

Parameters

format

The format of the date to be returned. Typically : yyyy-MM-dd HH:mm:ss

Example


console(formatDate("yyyy-MM-dd'T'HH:mm:ssXXX",timestamp()+24*3600*1000))  // -> 2022-07-22T09:36:04+01:00


Symbol Meaning Presentation Example
G era designator Text AD
y year Number 2009
M month in year Text & Number July & 07
d day in month 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 millisecond Number 978
E day in week Text Tuesday
D day in year Number 189
F day of week in month Number 2 (2nd Wed in July)
u day of the week in number Number 3 (1 = Monday, 7 = Sunday)
w week in year Number 27
W week in month Number 2
a am/pm marker Text PM
k hour in day (1-24) Number 24
K hour in am/pm (0-11) Number 0
z time zone Text Pacific Standard Time
escape for text Delimiter (none) single quote Literal (ex:yyyy 'year')


See also

nowFormat
timestamp
transformDate

timestamp

Returns the timestamp in milliseconds
The timestamp counts the number of milliseconds elapsed since January 1, 1970.

_locale (optional)

Default:"en". The region corresponding to the desired format (useful especially for day or month texts). Language code (ex: "en", "fr", "it", "de", etc.)

_returnObject (optional)

Default:false. If true, it returns the Java SimpleDateFormat object.