Symisc Systems

Libcox Command Reference


Star Follow @symisc

Command Syntax

date format [timestamp = time()]


Alias

None


Description

Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given. In other words, timestamp is optional and defaults to the value of time().The following are the supported format:

%a An abbreviated textual representation of the day
%A A full textual representation of the day
%d Two-digit day of the month (with leading zeros)
%e Day of the month, with a space preceding single digits.
%j Day of the year, 3 digits with leading zeros
%u ISO-8601 numeric representation of the day of the week 1 (for Monday) though 7 (for Sunday)
%w Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
%U Week number of the given year, starting with the first Sunday as the first week
%V ISO-8601:1988 week number of the given year, starting with the first week of the year with at least 4 weekdays, with Monday being the start of the week.
%W A numeric representation of the week of the year
%b Abbreviated month name, based on the locale
%B Full month name, based on the locale
%h Abbreviated month name, based on the locale (an alias of %b)
%m Two digit representation of the month
%C Two digit representation of the century (year divided by 100, truncated to an integer)
%g Two digit representation of the year going by ISO-8601:1988 standards (see %V)
%G The full four-digit version of %g
%y Two digit representation of the year
%Y Four digit representation for the year
%H Two digit representation of the hour in 24-hour format
%I Two digit representation of the hour in 12-hour format
%l (lower-case 'L') Hour in 12-hour format, with a space preceeding single digits
%M Two digit representation of the minute
%p UPPER-CASE 'AM' or 'PM' based on the given time
%P lower-case 'am' or 'pm' based on the given time
%r Same as "%I:%M:%S %p"
%R Same as "%H:%M"
%S Two digit representation of the second
%T Same as "%H:%M:%S"
%X Preferred time representation based on locale, without the date
%z Either the time zone offset from UTC or the abbreviation
%Z The time zone offset/abbreviation option NOT given by %z
%c Preferred date and time stamp based on local
%D Same as "%m/%d/%y"
%F Same as "%Y-%m-%d"
%s Unix Epoch Time timestamp (same as the time command)
%x Preferred date representation based on locale, without the time
%n A newline character ("\n")
%t A Tab character ("\t")
%% A literal percentage character ("%")

Parameters

format

The format of the outputted date string.

timestamp

Optional Parameter: The optional timestamp parameter is an integer Unix timestamp that defaults to the current local time if a timestamp is not given. In other words, it defaults to the value of time().


Return Value

String: A formatted date string. If a non-numeric value is used for timestamp, FALSE is returned. Use libcox_value_to_string() to extract the processing result.