- Theme Engine
- Design Principles
- Global variables
- Page templates
- Category templates
- Product templates
- EVML Reference
- Statements and Declarations
- Built-in Functions
- Built-in Objects
- EV Tags
- CSS Pre-processor
- Ajax API
Extends Object. Representation of date and time.
You can create an instance of the Date object as below.
<?ev var today = date(); // or var today = new Date(); ?>
If the dateString is not supplied the current date and time is assumed. The dateString may be any string that can be converted into a date and time Object. Here are some examples:
Note: Forward slash (/) signifies American M/D/Y formatting, a dash (-) signifies European D-M-Y and a period (.) signifies ISO Y.M.D. For example:
Due to confusion over date formats we have adopted a default display format that's easier to read:
Dates and time are subject to timezones and are always stored and extracted from the database with the server's timezone, but are output to screen using the timezone for the current locale. When instantiating a Date object using EV Script the timezone of the current locale is assumed if this parameter is omitted. The timezone should be a valid identifier such as 'Europe/London'.
The day as a two digit string e.g. 01 for 1st of the month
The day represented as a string e.g. Monday - Sunday
The hours as a two digit string in 24 hours e.g. 14 for 2pm
The minutes as a two digit string e.g. 01
The month as a two digit string e.g. 01 for January
The seconds as a two digit string e.g. 01
The time in H:i format e.g. 21:00 for 9pm
The unix timestamp representing the date.
The year in full i.e. 2015
A String representation of the Date object using the current locale's timezone. When the formatString is omitted the default format of d M Y is used e.g. 08 Aug 2015 (we rarely need to output time).
See supported formats below.
Modifies the current Date object by a given amount and returns the original modified Date object.
The default representation of the Date as a String using format().
Date & time formats
The following formats are supported:
|Y||Year as 4 digits||2015|
|y||Year as 2 digits||15|
|F||A full textual representation of a month||August|
|m||Numeric representation of a month, with leading zeros||08|
|M||A short textual representation of a month, three letters||Aug|
|n||Numeric representation of a month, without leading zeros||8|
|t||Number of days in the given month||31|
|d||Day of the month, 2 digits with leading zeros||08|
|D||A textual representation of a day, three letters||Sat|
|j||Day of the month without leading zeros||8|
|l||A full textual representation of the day of the week (lowercase L)||Saturday|
|S||English ordinal suffix for the day of the month, 2 characters (works well with j)||th|
|w||Numeric representation of the day of the week (0 for Sunday - 6 for Saturday)||6|
|z||Day of the year out of 365||0-365|
|g||12-hour format of an hour without leading zeros||1-12|
|G||24-hour format of an hour without leading zeros||0-23|
|h||12-hour format of an hour with leading zeros||01-12|
|H||24-hour format of an hour with leading zeros||01-23|
|i||Minutes with leading zeros||00-59|
|s||Seconds, with leading zeros||00-59|
|AM or PM|
|a||Lowercase Ante meridiem and Post meridiem||am / pm|
|A||Uppercase Ante meridiem and Post meridiem||AM / PM|
|O||Difference to Greenwich time (GMT) in hours||+0200|
|P||Difference to Greenwich time (GMT) with colon between hours and minutes||+02:00|