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
Parameter | Description |
---|---|
format | The required format of the date |
Date Formats - case sensitive:
Example WebDNA code:
Format | Description |
---|---|
%a | Abbreviated day name "Wed" |
%A | Full day name "Wednesday" |
%b | Abbreviated month name "Feb" |
%B | Full month name "February" |
%c | Date and time "Wed Sep 19 18:24:21 2010" |
%d | Day of month "01-31" |
%j | Day of year "001-365" |
%m | Month "01-12" |
%U | Week # of year, Sunday first day of week |
%w | Weekday "0" (Sunday) - "6" (Saturday) |
%W | Week # of year, Monday first day of week |
%x | Date as "Jan 25 2022" |
%y | Year without century "00-99" |
%Y | Year 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".
[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