StringTools - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Date and Time Routines : StringTools/FormatTime

StringTools

  

FormatTime

  

return a string containing a formatted date or time

 

Calling Sequence

Parameters

Description

Examples

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.

Examples

withStringTools:

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

FormatTime

2016-02-17

(1)

FormatTime%Y-%m-%d

2016-02-17

(2)

FormatTime%Y-%m-%d,0

2016-02-17

(3)

FormatTime%Y-%m-%d,606024

2016-02-16

(4)

FormatTime%Y-%m-%d,timestamp=0

1969-12-31

(5)

FormatTime%Y-%m-%d,timestamp=iolib25

2016-02-17

(6)

FormatTime%Y-%m-%d,timestamp=iolib25606024

2016-02-16

(7)

FormatTime%Y-%m-%d,offset=606024

2016-02-18

(8)

seqprintf%%%s - %s ,ch,FormatTimecat%,ch,ch=%aAbBcCdDeHIjklmMprRSTuUVwxXyYZ

%% - %
%a - Wed
%A - Wednesday
%b - Feb
%B - February
%c - Wed Feb 17 01:50:14 2016
%C - 20
%d - 17
%D - 02/17/16
%e - 17
%H - 01
%I - 01
%j - 048
%k -  1
%l -  1
%m - 02
%M - 50
%p - AM
%r - 01:50:14 AM
%R - 01:50
%S - 14
%T - 01:50:14
%u - 3
%U - 07
%V - 07
%w - 3
%x - 02/17/16
%X - 01:50:14
%y - 16
%Y - 2016
%Z - EST

See Also

epoch

FormatMessage

printf

sscanf

string

StringTools

StringTools[ParseTime]

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam