- Theme Engine
- Design Principles
- Templates
- EVML Reference
- Output
- Comments
- Operators
- Statements and Declarations
- Built-in Functions
- Built-in Objects
- Account
- Address
- Array
- Boolean
- Branch
- Cart
- CartLine
- Category
- CategoryCollection
- CategoryFilter
- CategoryFilterCollection
- CategoryFilterOption
- CategorySearch
- Collection
- Color
- Contact
- Currency
- Date
- Discount
- Dom
- Event
- EventCollection
- EventSlot
- Image
- Layout
- Locale
- Money
- Number
- Object
- Page
- PageCollection
- PageSearch
- PageSharer
- Pagination
- Postage
- Price
- PriceDiscount
- Product
- ProductCollection
- ProductCustomisation
- ProductDownload
- ProductMedia
- ProductMediaFrame
- ProductPrice
- ProductSearch
- ProductSpecification
- ProductSpecificationValue
- ProductVariation
- ProductVariationOption
- RecentlyViewed
- RegExp
- Request
- Review
- ReviewCollection
- Search
- SearchCollection
- SearchResult
- String
- Tag
- Template
- Url
- Website
- EV Tags
- CSS Pre-processor
- Ajax API
Date
Extends Object. Representation of date and time.
Instantiation
You can create an instance of the Date object as below.
<?ev
var today = date();
// or
var today = new Date();
?>
Construct parameters | |
---|---|
dateString |
String (optional) 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:
|
timezone |
String (optional) 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'. |
Properties | |
---|---|
day |
Type String The day as a two digit string e.g. 01 for 1st of the month |
dayOfWeek |
Type String The day represented as a string e.g. Monday - Sunday |
hours |
Type String The hours as a two digit string in 24 hours e.g. 14 for 2pm |
minutes |
Type String The minutes as a two digit string e.g. 01 |
month |
Type String The month as a two digit string e.g. 01 for January |
seconds |
Type String The seconds as a two digit string e.g. 01 |
time |
Type String The time in H:i format e.g. 21:00 for 9pm |
timestamp |
Type Number The unix timestamp representing the date. |
year |
Type String The year in full i.e. 2015
|
Methods | |
---|---|
format([String:format]) |
Returns String 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. |
modify(String:modify) |
Returns Date Modifies the current Date object by a given amount and returns the original modified Date object.
|
toString() |
Returns String The default representation of the Date as a String using format(). |
Date & time formats
The following formats are supported:
Year | Example | |
Y | Year as 4 digits | 2015 |
y | Year as 2 digits | 15 |
Month | ||
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 |
Day | ||
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 |
Hours | ||
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 |
Minutes | ||
i | Minutes with leading zeros | 00-59 |
Seconds | ||
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 |
Time (other) | ||
O | Difference to Greenwich time (GMT) in hours | +0200 |
P | Difference to Greenwich time (GMT) with colon between hours and minutes | +02:00 |