date

  • The default format of [date] is MM/DD/YYYY, date format can be changed in WebDNA Preference Settings.
  • Putting [date] in a template displays the current date as defined by the clock of the web server
  • Override the default [date] format preference on a case-by-case basis by specifying a format inside the tag, as shown below.

Parameters

ParameterDescription
formatThe required format of the date
Date Formats - case sensitive:
FormatDescription
%aAbbreviated day name "Wed"
%AFull day name "Wednesday"
%bAbbreviated month name "Feb"
%BFull month name "February"
%cDate and time "Wed Sep 19 18:24:21 2010"
%dDay of month "01-31"
%jDay of year "001-365"
%mMonth "01-12"
%UWeek # of year, Sunday first day of week
%wWeekday "0" (Sunday) - "6" (Saturday)
%WWeek # of year, Monday first day of week
%xDate as "Jan 25 2022"
%yYear without century "00-99"
%YYear with century "1900-2199"

Example WebDNA code:
Formats in the [date] tag can be combined with ordinary characters, 
such as the comma, slash and space
[date] returns: 08/14/2022
[date %A, %B %d, %Y] returns: Thursday, August 14, 2022
[date %m/%d/%Y] returns: 08/14/2022
[date %d/%m/%Y] returns: 14/08/2022
[date format=%A, %B %d, %Y] returns: Thursday, August 14, 2022
[date %Z] returns: UTC
[date %s] returns: 1670966773

The [date] tag is sometimes confused with [orderfile]'s [date] tag, these are different. The [date] tag inside the context of an [orderfile] represents the date the order was created, and does not have the ability to be custom formatted. If today's date is required inside an [orderfile], then a text variable must first be assigned outside the [orderfile] context, and use that text variable.

Example WebDNA code:
[text]todaysdate=[date][/text]
[orderfile cart=[cart]]
  Order Date: [date]
  Today: [todaysdate]
[/orderfile]

Ambiguous dates/times
If a date contain a decimal point "." then the [math] context will interpret them as a time instead of a date. It is possible to force WebDNA to interpret text as a date by inserting a "D" in front of the text, example: [math]{D10.01.2022}[/math]. Alternately it is possible to force time interpretation by using "T".

Mix time & date WebDNA code:
[time] and [date] tags can be mixed by using the "%" formatting switches
[time %A, %I:%M %p] returns: Friday, 2:30 PM
[date %A, %I:%M %p] returns: Friday, 2:30 PM