viv:format-date
formats a date expressed in Unix time (seconds since standard epoch of Jan 1, 1970) using an optional format string
Synopsis
string viv:format-date (seconds, format); string seconds; string format;
Description
The viv:format-date function requires one argument, which is the date/time (expressed in Unix date-seconds) that is to be formatted. This is often the output value produced by the viv:parse-date function.
The viv:format-date function also accepts an optional second argument, which is a format string composed of the same format specifiers as are accepted by the standard strftime function. If the second argument is not present, the date/time output format defaults to "%Y-%m-%dT%H:%M:%S%z" (RFC 3339 format).
This function supports the following formatting codes:
- %a or %A - The day-of-the-week name, either abbreviated (e.g. "Mon") or full (e.g. "Monday").
- %b or %B - The month name, either abbreviated (e.g. "Jan") or full (e.g. "January").
- %c - The preferred date and time representation for the current locale.
- %d - The day of the month (1-31).
- %H - The hour in 24-hour format (00-23), as a 2-digit number.
- %I - The hour in 12-hour format (01-12), as a 2-digit number.
- %j - The day number in the year (1-366), with or without leading zeros.
- %m - The month number (1-12).
- %M - The minute (0-59).
- %p - "AM" or "PM", or "am" or "pm". Required when using 12-hour format.
- %S - The seconds (0-61).
- %U - The week number in the year (0-53), where Sunday is the first day of the week.
- %w - The weekday number (0-6), where 0 is Sunday.
- %W - The week number in the year (0-53), where Monday is the first day of the week.
- %y - The 2-digit year, where 69-99 refer to 1969-1999 and 00-68 refer to 2000-2068.
- %Y - The 4-digit year.
- %Z - The time zone name or abbreviation.
- %% - The % character.
Arguments
- seconds: A number of seconds since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).
- format: A format string composed of the same format specifiers that are acceptd by the strftime() function.
Returns
A string representing the date/time in a human-readable format.