> ## Documentation Index
> Fetch the complete documentation index at: https://dokumentation.websale.de/llms.txt
> Use this file to discover all available pages before exploring further.

# DC- (date and time)

> Output the server time in the template, switch areas by date, time, or day of the week, and measure runtimes.

A template can look at the clock. This lets you display notices on a schedule without anyone having to remove them manually again: an Advent calendar in December, a notice about the shipping cut-off at 3 p.m., a different text on the weekend.

All time tags work with the **server time**, not with the visitor's clock.

## Set first, then output

The time details come from a point in time that you define at the beginning. `DC-DateTime_set()` does this.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~DC-DateTime_set~

Heute ist der ~DC-DateTime_day(true)~.~DC-DateTime_month(true)~.~DC-DateTime_year~,
es ist ~DC-DateTime_hours(true)~:~DC-DateTime_minutes(true)~ Uhr.

<!-- am 06.02.2018 um 11:21 Uhr: Heute ist der 06.02.2018, es ist 11:21 Uhr. -->
```

> [!WARNING]
>
> Set the point in time before you output or query any of its components. All subsequent tags refer to this one point in time and not to the moment at which they themselves are parsed.

### Setting a different point in time

`DC-DateTime_set()` accepts an offset in seconds. You use it to calculate into a different time zone or into the future.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~DC-DateTime_set(3600)~     <!-- Serverzeit plus eine Stunde -->
~DC-DateTime_set(-86400)~   <!-- Serverzeit minus einen Tag -->
```

`DC-DateTime_setunixtimestamp()` instead sets an absolute point in time. The argument supports tag-in-tag, so the point in time can come from another tag.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~DC-DateTime_setunixtimestamp($WS-SubSequentOrder_TimestampExpire$)~

Ihre Bestellung gilt bis ~DC-DateTime_day(true)~.~DC-DateTime_month(true)~.~DC-DateTime_year~
um ~DC-DateTime_hours(true)~:~DC-DateTime_minutes(true)~ Uhr.
```

> [!NOTE]
>
> If the argument is empty or not a number, the shop sets the point in time to now. An incorrect value therefore does not lead to a wrong date from the year 1970, but to the current server time.

> [!NOTE]
>
> `DC-DateTime_unixtimestamp` outputs the point in time just set as a UNIX timestamp. This is useful for passing it to a third-party system or to JavaScript. The tag is not described in the previous documentation, but it exists in the shop.

## Outputting the components

| Tag | Returns | Value range |
| - | - | - |
| `DC-DateTime_day()` | the day of the month | 1 to 31 |
| `DC-DateTime_month()` | the month | 1 to 12 |
| `DC-DateTime_year()` | the year, four digits | |
| `DC-DateTime_hours()` | the hour | 0 to 23 |
| `DC-DateTime_minutes()` | the minute | 0 to 59 |
| `DC-DateTime_seconds()` | the second | 0 to 59 |
| `DC-DateTime_dayofweek()` | the day of the week as an English abbreviation | `mon` to `sun` |
| `DC-DateTime_unixtimestamp` | the point in time as a UNIX timestamp | |

### Leading zeros

By default, the numbers come without a leading zero. The argument `true` switches it on.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~DC-DateTime_day~          <!-- 7 -->
~DC-DateTime_day(false)~   <!-- 7 -->
~DC-DateTime_day(true)~    <!-- 07 -->
```

> [!NOTE]
>
> `DC-DateTime_year()` does not make this distinction and always outputs four digits. An argument has no effect there.

## Switching areas by time

All components can be bracketed. The area appears if the value matches the argument.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~DC-DateTime_set~

{DC-DateTime_month(12)}
   <p>Unsere Weihnachtsaktion läuft.</p>
{/DC-DateTime_month(12)}

{DC-DateTime_hours(6)}
   <p>Guten Morgen!</p>
{/DC-DateTime_hours(6)}

{!DC-DateTime_month(12)}
   <p>Text außerhalb des Dezembers.</p>
{/!DC-DateTime_month(12)}
```

> [!WARNING]
>
> Exactly one value is compared, not a range. For "from 9 a.m. to 5 p.m.", you therefore need the comparison tags, for example `DC-CompareDigitIB()`, and pass them the hour as tag-in-tag.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{DC-CompareDigitIB($DC-DateTime_hours$,9,17)}
   <p>Unser Service ist gerade erreichbar.</p>
{/DC-CompareDigitIB($DC-DateTime_hours$,9,17)}
```

Reference: DC-CompareDigitIB()

### The day of the week

As a range tag, `DC-DateTime_dayofweek()` accepts a comma-separated list of days of the week.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~DC-DateTime_dayofweek~   <!-- mon, tue, wed, thu, fri, sat oder sun -->

{DC-DateTime_dayofweek(mon,tue,wed,thu,fri)}
   <p>Bestellungen bis 15 Uhr gehen heute noch raus.</p>
{/DC-DateTime_dayofweek(mon,tue,wed,thu,fri)}

{DC-DateTime_dayofweek(sat,sun)}
   <p>Am Wochenende versenden wir nicht.</p>
{/DC-DateTime_dayofweek(sat,sun)}
```

> [!NOTE]
>
> Only the first three characters are compared, and upper and lower case do not matter. `{DC-DateTime_dayofweek(Monday)}` therefore applies just like `{DC-DateTime_dayofweek(mon)}`. Nevertheless, stick to the abbreviation so that it is clear in the template what the tag actually compares.

## Measuring runtimes

`DC-Timer1…3` measures how long the shop takes for a section of the template. Three independent timers are available.

| Tag | Effect |
| - | - |
| `DC-Timer1…3_start` | starts the measurement |
| `DC-Timer1…3_stop` | ends it |
| `DC-Timer1…3` | outputs the measured duration in milliseconds |

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~DC-Timer1_start~
<!doctype html>
<html>
   ~DC-Timer2_start~
   <head>
      ...
   </head>
   ~DC-Timer2_stop~

   <body>
      ...
   </body>
</html>
~DC-Timer1_stop~

<!-- Gesamt: ~DC-Timer1~ ms, davon Kopfbereich: ~DC-Timer2~ ms -->
```

> [!NOTE]
>
> A useful pattern: timer 1 encloses the entire template and returns the total duration, while the other two narrow down the suspicious sections.

> [!WARNING]
>
> The timers only work in templates that can be called directly in the browser. In include files, for example FastInclude files, they do not measure.

> [!WARNING]
>
> Do not leave the measured values visible in the shop. They belong in an HTML comment or in a template that is only called internally.

## Overview of the tags

| Tag | Single tag | Range tag | Negative range tag | Loop tag |
| - | - | - | - | - |
| `DC-DateTime_set()` | yes | – | – | – |
| `DC-DateTime_setunixtimestamp()` | yes | – | – | – |
| `DC-DateTime_unixtimestamp` | yes | – | – | – |
| `DC-DateTime_day()` | yes | yes | yes | – |
| `DC-DateTime_month()` | yes | yes | yes | – |
| `DC-DateTime_year()` | yes | yes | yes | – |
| `DC-DateTime_hours()` | yes | yes | yes | – |
| `DC-DateTime_minutes()` | yes | yes | yes | – |
| `DC-DateTime_seconds()` | yes | yes | yes | – |
| `DC-DateTime_dayofweek()` | yes | yes | yes | – |
| `DC-Timer1…3` | yes | – | – | – |
| `DC-Timer1…3_start` | yes | – | – | – |
| `DC-Timer1…3_stop` | yes | – | – | – |

All tags are permitted in all templates, except for the timers, which do not measure in include files.

## Related topics

* Reference: DC- (comparisons and other tags)
* Reference: DC- (free parameters and session parameters)
* Basics: Tag basics


## Related topics

- [SUBS- (managing subscriptions)](https://dokumentation.websale.de/en/v8s/referenz/tags/subs/abos-verwalten.md)
- [Show the date and time of the last update](https://dokumentation.websale.de/en/v8s/einstellungen/datum-und-uhrzeit-der-letzten-aktualisierung-anzeigen.md)
- [Orders and commissions](https://dokumentation.websale.de/en/v8s/referenz/tags/affiluser/bestellungen-und-provisionen.md)
- [E-PRODRATING-EKOMI_ (eKomi product rating)](https://dokumentation.websale.de/en/v8s/referenz/tags/e-prodrating-ekomi.md)
- [AL- (AutoLogin)](https://dokumentation.websale.de/en/v8s/referenz/tags/al-autologin.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.