datetime.format
This function displays the date according to the specified format. The format uses MM(month), DD(day), YYYY(year), hh(hour), mm(minute), and ss(second). Except MM, the rest are not case-sensitive. The datetime format can also be set with a predefined layout ANSIC, UnixDate, RubyDate, RFC822, RFC822Z, RFC850, RFC1123, RFC1123Z, RFC3339 and RFC3339Nano.
Syntax
datetime.format(datetime, format)
Arguments
Argument |
Type |
Description |
---|---|---|
datetime |
datetime |
Date and time to be formatted. |
format |
string |
Format to be used for the date and time. |
Returns
Type |
Description |
---|---|
string |
Date and time in the specified format. |
Examples
The function datetime.format(datetime.current(), "RFC3339")
returns the current date and time in RFC3339 format.