B.66 TstampTask

Sets the DSTAMP, TSTAMP, and TODAY properties in the current project. By default, the DSTAMP property is in the format "yyyyMMdd", TSTAMP is in the format "HHmm", finally TODAY contains locale-sensitive date, for example "March 13, 2023". Use the nested <format> element to specify a different format.

These properties can be used in the build-file, for instance, to create time-stamped filenames, or used to replace placeholder tags inside documents to indicate, for example, the release date. The best place for this task is probably in an initialization target.

The magic property phing.tstamp.now can be used to specify a fixed date value in order to create reproducible builds. Its value must be a number and is interpreted as seconds since the epoch (midnight 1970-01-01). With phing.tstamp.now.iso you could also specify that value in DateTime compatible format. If you specify a value in an invalid format an INFO message will be logged and the value will be ignored.

Table B.70: Attributes

NameTypeDescriptionDefaultRequired
prefix String Prefix used for all properties set.n/aNo

B.66.1 Examples

<tstamp/>

sets the standard DSTAMP, TSTAMP, and TODAY properties according to the default formats.

<tstamp>
    <format property="DAY" pattern="EEEE" locale="nl_NL"/>
</tstamp>

sets the standard properties as well as the property DAY with the pattern "EEEE" (day of week) using the Dutch locale.

<tstamp prefix="start"/>

sets three properties with the standard formats, prefixed with "start.": start.DSTAMP, start.TSTAMP, and start.TODAY.

B.66.2 Supported Nested Tags

  • format

    The Tstamp task supports a <format> nested element that allows a property to be set to the current date and time in a given format.

Table B.71: Attributes

NameTypeDescriptionDefaultRequired
property String The property to receive the date/time string in the given pattern.n/aYes
pattern String The date/time pattern to be used, pattern must follow ICU syntax.n/aYes
locale String The locale used to create date/time string. n/aNo
timezone String The timezone to use for displaying time.n/aNo

B.66.3 ICU syntax

ICU syntax replaces string of characters with proper date and time data. Please refer to official ICU documentation to see the complete Date/Time Format Syntax reference.

Table B.72: ICU syntax

SymbolMeaningPatternExample Output
y year yy
y or yyyy
96
1996
M month in year M
MM
MMMM
9
09
September
d day in month d
dd
2
02
E day of week E, EE, or EEE
EEEE
Tue
Tuesday
a AM or PM a, aa, or aaa
aaaa
PM [abbrev]
PM [wide]
h hour in am/pm (1~12) h
hh
7
07
H hour in day (0~23) H
HH
0
00
m minute in hour m
mm
4
04
s seconds in minute s
ss
5
05
Z Time Zone: ISO8601 basic hms? / RFC 822
Time Zone: long localized GMT (=OOOO)
Time Zone: ISO8601 extended hms? (=XXXXX)
Z, ZZ, or ZZZ
ZZZZ
ZZZZZ
-0800
GMT-08:00
-08:00, -07:52:58, Z
' escape for text ' (nothing)
' ' two single quotes produce one ' ' '

Note

ICU syntax was introduced in Phing 3, if you are using an older version then you must use strftime format syntax.