Skip to main content
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.
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.
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.
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.
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

Leading zeros

By default, the numbers come without a leading zero. The argument true switches it on.
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.
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.
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.
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.
A useful pattern: timer 1 encloses the entire template and returns the total duration, while the other two narrow down the suspicious sections.
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.
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

All tags are permitted in all templates, except for the timers, which do not measure in include files.
  • Reference: DC- (comparisons and other tags)
  • Reference: DC- (free parameters and session parameters)
  • Basics: Tag basics