FormatTime - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

StringTools

 FormatTime
 return a string containing a formatted date or time

 Calling Sequence FormatTime( fmt, option )

Parameters

 fmt - (optional) string option - (optional) integer offset or an equation of the form timestamp = integer[4] or of the form offset = integer[4]

Description

 • The FormatTime(fmt, option) command returns a string containing a formatted date and time. Both the format string fmt and the integer time displacement or equation option are optional. The default format is the ISO 8601 standard default date format, which has the form YYYY-MM-DD, where "Y" denotes a year digit, "M" denotes a digit of the month (01-12), and "D" denotes a digit of the day of the month (01-31). The default time displacement is $0$ (the current time).
 • The time format string is a Maple string that can contain time and date format conversion specifiers, introduced by a $"%"$ character. This works in a manner similar to the conversion specifiers used in printf or sscanf, but the defined conversion specifiers are different. The format string is copied to the output, but conversion specifiers are replaced with their meanings with respect to the option argument, if present, or the current date and time if no option argument is supplied. A literal $"%"$ character can be included in the format string by using $"%%"$.
 • The following table lists the known conversion specifiers and their meanings.

 %% the string "%". %a abbreviated weekday name. %A the full weekday name. %b abbreviated month name. %B full month name. %c a standard date and time representation. %C the century number (the year divided by 100 and truncated to an integer in the range 00 - 99). %d the two-digit day of the month number (01-31). %D the date in the form MM/DD/YY. %e the day of the month (1-31). %H the hour in a 24-hour clock (00-23). %I the hour in a 12-hour clock (01-12). %j day number (01 - 366). %k the hour in a 24-hour clock ( 0-23). %l the hour in a 12-hour clock ( 1-12). %m the month number (01 - 12). %M the minute after the hour (00-59). %n a newline character. %p a.m. or p.m. %r time representation for a 12-hour clock (using %p). %R the same as %H:%M. %S seconds after the minute (00 - 61). %t a tab character. %T same as %H:%M:%S. %u weekday as a decimal number (1-7; 1 = Monday). %U week number of the year (00 - 53); Sunday is the first day of week 1. %V The ISO 8601 week number (01 - 53). %w weekday (0-6); 0 = Sunday. %x a standard date representation. %X a standard time representation. %y year within the century (00 - 99). %Y year including the century (YYYY). %Z time zone name or abbreviation, if available.

 • Integer offsets passed via the second parameter must be 32-bit integers.
 • All of the StringTools package commands treat strings as (null-terminated) sequences of $8$-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$

The following examples reflect the date on which the help page output was generated.

 > $\mathrm{FormatTime}\left(\right)$
 ${"2023-03-08"}$ (1)
 > $\mathrm{FormatTime}\left("%Y-%m-%d"\right)$
 ${"2023-03-08"}$ (2)
 > $\mathrm{FormatTime}\left("%Y-%m-%d",0\right)$
 ${"2023-03-08"}$ (3)
 > $\mathrm{FormatTime}\left("%Y-%m-%d",-60\cdot 60\cdot 24\right)$
 ${"2023-03-07"}$ (4)
 > $\mathrm{FormatTime}\left("%Y-%m-%d",\mathrm{timestamp}=0\right)$
 ${"1969-12-31"}$ (5)
 > $\mathrm{FormatTime}\left("%Y-%m-%d",\mathrm{timestamp}=\mathrm{iolib}\left(25\right)\right)$
 ${"2023-03-08"}$ (6)
 > $\mathrm{FormatTime}\left("%Y-%m-%d",\mathrm{timestamp}=\mathrm{iolib}\left(25\right)-60\cdot 60\cdot 24\right)$
 ${"2023-03-07"}$ (7)
 > $\mathrm{FormatTime}\left("%Y-%m-%d",\mathrm{offset}=60\cdot 60\cdot 24\right)$
 ${"2023-03-09"}$ (8)
 > $\mathrm{seq}\left(\mathrm{printf}\left("%%%s - %s",\mathrm{ch},\mathrm{FormatTime}\left(\mathrm{cat}\left("%",\mathrm{ch}\right)\right)\right),\mathrm{ch}="%aAbBcCdDeHIjklmMprRSTuUVwxXyYZ"\right)$
 %% - % %a - Wed %A - Wednesday %b - Mar %B - March %c - Wed Mar 08 01:06:47 2023 %C - 20 %d - 08 %D - 03/08/23 %e -  8 %H - 01 %I - 01 %j - 067 %k -  1 %l -  1 %m - 03 %M - 06 %p - AM %r - 01:06:47 AM %R - 01:06 %S - 47 %T - 01:06:47 %u - 3 %U - 10 %V - 10 %w - 3 %x - 03/08/23 %X - 01:06:47 %y - 23 %Y - 2023 %Z - EST

 See Also epoch