Format Date/Time String

Displays the date and time in seconds since 12:00 a.m., January 1, 1904, Universal time, in a format you specify. Time format codes include the following: %H (hour, 24-hour clock), %I (hour, 12-hour clock), %M (minute), %S (second), %p (a.m./p.m. flag), %d (day of month), %m (month number), %y (year within century), %Y (year including century), %a (abbreviated weekday name), %x (locale-specific date), %X (locale-specific time), %c (locale-specific date/time), %<digit>u (fractional seconds with <digit> precision). Details

time format string specifies the format of the output string. Time format codes (beginning with %) not recognized by the function as a format code return the character literally. The default code is %c, which corresponds to the date/time representation appropriate for the current locale. If time format string is an empty string, the function uses the default.
seconds, which is the number of seconds since 12:00 a.m., January 1, 1904, Universal Time. The default is the current time.
date/time string is the formatted date/time string.

Format Date/Time String Details

This function calculates date/time string by copying time format string and replacing each of the time format codes with the corresponding values.

Time format codes have leading zeros as necessary to ensure a constant field width. An optional # modifier before the format code letter removes the leading zeros from the following format codes:

%#d, %#H, %#I, %#j, %#m, %#M, %#s, %#S, %#U, %#w, %#W, %#X, %#y, %#Y

The # modifier does not modify the behavior of any other format codes.

Note  The %c, %x, %X, and %Z format codes depend on operating system locale support. The output of these codes is platform dependent. Interpretation of the Daylight Savings Time rule also can vary by platform.