time_stamp

Top  Previous  Next

Scripts > Class elements and c++ instructions > Other functions > time_stamp

Prototype

 

str time_stamp()

str time_stamp(const str& xsFormat)

 

 

Description

 

Converts the present date and time into a string. If the function is called without parameter or with an empty string, then the resulting string contains 26 characters in the following format:

 

Mon Nov 21 11:31:54 1983\n

 

To get another format, the function can be called with a format string. This string is a combination of normal text and formatting characters followed on "%". The possible formatting characters are listed in the following table:

 

Format character

Meaning

Example

a

Abbreviated weekday name

Sun

A

Full weekday name

Sunday

b

Abbreviated month name

Feb

B

Full month name

February

c

Date and time

Feb 29 14:34:56 1984

d

Day of the month

29

H

Hour of the 24-hour day

14

I

Hour of the 12-hour day

02

j

Day of the year, from 001

60

m

Month of the year, from 01

02

M

Minutes after the hour

34

p

AM/PM indicator, if any        AM

AM

S

Seconds after the minute

56

U

Sunday week of the year, from 00


w

Day of the week, with 0 for Sunday

0

W

Monday week of the year, from 00


x

Date

Feb 29 1984

X

Time

14:34:56

y

Year of the century, from 00 (deprecated)

84

Y

Year

1984

Z

Time zone name

PST or PDT

 

Only those parts that are actually used are noted

 

Return value

 

A string with date and time

 

 

Examples

 

out << time_stamp() << endl;

out << time_stamp("It is %M minutes after %I o'clock (%Z)  %A, %B %d %Y") << endl;

out << time_stamp("It is %M minutes after %I o'clock (%Z)") << endl;

out << time_stamp("%A, %B %d %Y") << endl;

 

results in:

 

Tue Oct 23 00:34:51 2007

 

It is 34 minutes after 12 o'clock ()  Tuesday, October 23 2007

It is 34 minutes after 12 o'clock ()

Tuesday, October 23 2007

 

when writing this help section.

 



This page belongs to the TextTransformer Documentation

Home  Content  German