# <tstamp>

Sets properties with the current date and time.

By default the <tstamp> task displays the current date and time and sets the following properties:

- tstamp.date to yyyyMMdd
- tstamp.time to HHmm
- tstamp.now using the default DateTime.ToString() method

To set an additional property with a custom date/time use the `property` and `pattern` attributes. To set a number of additional properties with the exact same date and time use the `formatter` nested element (see example).

The date and time string displayed by the <tstamp> task uses the computer's default long date and time string format. You might consider setting these to the ISO 8601 standard for date and time notation.

### Parameters

Attribute | Type | Description | Required
--- | --- | --- | ---
pattern | string | The date/time pattern to be used. | False
property | string | The property to receive the date/time string in the given pattern. | False
failonerror | bool | Determines if task failure stops the build, or is just reported. The default is true. | False
if | bool | If true then the task will be executed; otherwise, skipped. The default is true. | False
unless | bool | Opposite of `if`. If false then the task will be executed; otherwise, skipped. The default is false. | False
verbose | bool | Determines whether the task should report detailed build log messages. The default is false. | False

### Nested Elements:

#### <formatter>

### Parameters

Attribute | Type | Description | Required
--- | --- | --- | ---
pattern | string | The string pattern to use to format the property. | True
property | string | The name of the NAnt property to set. | True
if | bool | Indicates if the formatter should be used to format the timestamp. If true then the formatter will be used; otherwise, skipped. The default is true. | False
unless | bool | Indicates if the formatter should be not used to format the timestamp. If false then the formatter will be used; otherwise, skipped. The default is false. | False

#### </formatter>

### Examples

- Set the `build.date` property.

      <tstamp property="build.date" pattern="yyyyMMdd" verbose="true" />

- Set a number of properties for Ant like compatibility.

      <tstamp verbose="true">
          <formatter property="TODAY" pattern="dd MMM yyyy"/>
          <formatter property="DSTAMP" pattern="yyyyMMdd" unless="${date.not.needed}" />
          <formatter property="TSTAMP" pattern="HHmm" if="${need.hours}" />
      </tstamp>

### Requirements

Assembly: NAnt.Core (0.91.4312.0)