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 rests are not case-sensitive. The datetime format can also be set with a following predefined layout:
- ANSIC
- Unix Date
- RubyDate
- RFC822
- RFC822Z
- RFC850
- RFC1123
- RFC1123Z
- RFC3339,
- 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.