Date
Date – Creates a Date object.
Description
new Date([mixed date, [integer month, [integer day, [integer hour, [integer minutes, [integer seconds, [integer milliseconds]]]]]]])
The range of dates that can be represented in a Date object is approximately 100000000 days (270000 years) on either side of 1 January 1970.
Parameters
Name | Description | Type | Default | Optional |
---|---|---|---|---|
date | See date below. | mixed | Yes | |
month | Integer between 0 and 11. | integer | Yes | |
day | Integer between 1 and 31. | integer | Yes | |
hour | Integer between 0 and 23. | integer | Yes | |
minutes | Integer between 0 and 59. | integer | Yes | |
seconds | Integer between 0 and 59. | integer | Yes | |
milliseconds | Integer between 0 and 999. | integer | Yes |
Date parameter
Can be a date string, timestamp or year if multiple paramters is provided.
- Not provided
Current time.
- Year
-
If called with multiple parameters, the first one will be assumed to be the year.
This input is local time.
- Integer
If date is provided as an integer, it sill be number of milliseconds since 1 January 1970 00:00:00 UTC.
- String
-
String value representing a date.
This input is local time if no timezone is specified.
Examples
Example #1 – Date example