Date Class
Represents date and time. Local and UTC timezones supported.
Example:
var d = new Date();
console.printf("today is: %d-%d-%d %d:%d:%d\n", d.day, d.month, d.year, d.hour, d.minute, d.second);
// UTC
d = new Date("28 Feb 1980 UTC");
if (d.UTCday != 28 || f.UTCmonth != 2 || d.UTCyear != 1980) throw "date ctor";
// Locale strings
console <<<< d.toLocaleString(true, 1);
Item Index
Methods
- this constructor
- this constructor
- dayOfWeekName
- isDaylight
- monthName
- now
- parse
- setTime
- tick
- timeZoneName
- timeZoneOffset
- toISOString
- toLocaleString
- toString
- toUTCString
- UTC
- valueOf
Methods
this
[value]
Constructor - creates new date object. If no parameters were given then initializes date fields to the current time (UTC). If single string parameter provided then parses date contained in the string.
Returns:
Example:
var d = new Date();
this
[year]
[month]
[day]
[hour]
[minute]
[second]
[millisecond]
Constructor - creates new date object. If no parameters were given then initializes date fields to the current time (UTC). If single string parameter provided then parses date contained in the string.
Parameters:
-
[year]
Integer optionalfull number of the year, e.g. 2005.
-
[month]
Integer optionalnumber of the month, from 1 to 12.
-
[day]
Integer optionalnumber of the day, from 1 up to number of days in the month.
-
[hour]
Integer optionalhour, from 0 to 23.
-
[minute]
Integer optionalminute, from 0 to 59.
-
[second]
Integer optionalsecond, from 0 to 59.
-
[millisecond]
Integer optionalmillisecond, from 0 to 999.
Returns:
dayOfWeekName
longFormat
Find out name of the day in current user's locale.
Parameters:
-
longFormat
BooleanIf longFormat is equal true returns full week name, otherwise - it's abbreviation.
Returns:
isDaylight
() Boolean
Find out if current clock is using daylight saving time.
Returns:
monthName
longFormat
Find out name of the month in current user's locale.
Parameters:
-
longFormat
BooleanIf longFormat is equal true returns full month name, otherwise - it's abbreviation.
Returns:
now
[sequential=false]
Actual date
Parameters:
-
[sequential=false]
Boolean optionalThis ensures that two consequtive calls of Date.now(true) return distinct values.
Returns:
parse
value
This function parse date in string
Returns:
setTime
milliseconds
Sets this date object fields equal to date defined by milliseconds parameter.
Parameters:
-
milliseconds
Integernumber of milliseconds since midnight, January 1, 1970 UTC.
tick
() Integer
Number of miliseconds. This property is suitable for animation (game) scheduling.
Returns:
timeZoneOffset
() Integer
Returns shift in milliseconds of current timezone from GMT.
Returns:
toISOString
[asUTC=false]
Creates ISO 8601 string representation of this date object as either local or UTC date/time.
Parameters:
-
[asUTC=false]
Boolean optionalTrue for UTC time, false for local time. The default je false.
toLocaleString
longFormat
longFormat
Returns string representation of the date using current system settings.
Parameters:
-
longFormat
BooleanIf longFormat is equal exactly true then formats date using system long date format.
-
longFormat
IntegerThis parameter defines formatting style. Argument typeFormat can by one of: * 0 - result strings will containts both date and time part * 1 - string will represent only date part * 2 - only time part will be displayed in result string representation.
Returns:
UTC
[year]
[month]
[day]
[hour]
[minute]
[second]
[millisecond]
Calculate number of milliseconds since midnight, January 1, 1970 UTC up to date defined by parameters
Parameters:
-
[year]
Integer optionalfull number of the year, e.g. 2005.
-
[month]
Integer optionalnumber of the month, from 1 to 12.
-
[day]
Integer optionalnumber of the day, from 1 up to number of days in the month.
-
[hour]
Integer optionalhour, from 0 to 23.
-
[minute]
Integer optionalminute, from 0 to 59.
-
[second]
Integer optionalsecond, from 0 to 59.
-
[millisecond]
Integer optionalmillisecond, from 0 to 999.