Date
Module | ejs |
Namespace | intrinsic |
Definition | final class Date |
Inheritance | Date ![]() |
General purpose class for representing and working with dates, times, time spans, time zones and locales.
Properties
Qualifiers | Property | Type | Description |
---|---|---|---|
No properties defined |
Date Methods
Qualifiers | Method |
---|---|
Date(args: Array) | |
Construct a new date object. | |
public get | date(): Number |
Return the day of the month. | |
public get | day(): Number |
Return the day of the week in local time. | |
public get | dayOfYear(): Number |
Return the day of the year in local time. | |
public get | elapsed(): Number |
Time in milliseconds since the date object was constructed. | |
public | format(layout: String): String |
Return a formatted date string of the date. | |
public get | fullYear(): Number |
Return the year as four digits. | |
public set | fullYear(year: Number): Void |
Set the year as four digits according to the locale. | |
public | getDate(): Number |
Return the day of the month. | |
public | getDay(): Number |
Return the day of the week in local time. | |
public | getFullYear(): Number |
Return the year as four digits. | |
public | getHours(): Number |
Return the hour (0 - 23) in local time. | |
public | getMilliseconds(): Number |
Return the millisecond (0 - 999) in local time. | |
public | getMinutes(): Number |
Return the minute (0 - 59) in local time. | |
public | getMonth(): Number |
Return the month (1 - 12) in local time. | |
public | getSeconds(): Number |
Return the second (0 - 59) in local time. | |
public static | getTime(): Number |
Return the number of milliseconds since midnight, January 1st, 1970. | |
public | getTimezoneOffset(): Number |
Return the number of minutes between the local computer time and Coordinated Universal Time. | |
public get | hours(): Number |
Return the current hour (0 - 23) in local time. | |
public set | hours(hour: Number): Void |
Set the current hour (0 - 59) according to the locale. | |
public get | milliseconds(): Number |
Return the current millisecond (0 - 999) in local time. | |
public set | milliseconds(ms: Number): Void |
Set the current millisecond (0 - 999) according to the locale. | |
public set | minutes(min: Number): Void |
Set the current minute (0 - 59) according to the locale. | |
public get | minutes(): Number |
Return the current minute (0 - 59) in local time. | |
public get | month(): Number |
Return the current month (0 - 11) in local time. | |
public set | month(month: Number): Void |
Set the current month (0 - 11) according to the locale. | |
public | nanoAge(): Number |
Time in nanoseconds since the date object was constructed. | |
public | nextDay(inc: Number): Date |
Return a new Date object that is one day greater than this one. | |
public static | now(): Number |
Return the current time as milliseconds since Jan 1 1970. | |
public static | parse(arg: String, defaultDate: Number): Number |
Return a new Date object by parsing the argument string. | |
public static | parseDate(arg: String, defaultDate: Date): Date |
Return a new Date object by parsing the argument string. | |
public get | seconds(): Number |
Return the current second (0 - 59) in local time. | |
public set | seconds(sec: Number): Void |
Set the current second (0 - 59) according to the locale. | |
public | setDate(d: Number): Void |
Set the date of the month (0 - 31). | |
public | setFullYear(y: Number): Void |
Set the current year as four digits according to the locale. | |
public | setHours(h: Number): Void |
Set the current hour (0 - 59) according to the locale. | |
public | setMilliseconds(ms: Number): Void |
Set the current millisecond (0 - 999) according to the locale. | |
public | setMinutes(min: Number): Void |
Set the current minute (0 - 59) according to the locale. | |
public | setMonth(mon: Number): Void |
Set the current month (0 - 11) according to the locale. | |
public | setSeconds(sec: Number, msec: Number): Void |
Set the current second (0 - 59) according to the locale. | |
public static get | time(): Number |
Return the number of milliseconds since midnight, January 1st, 1970 and the current date object. | |
public static set | time(value: Number): Number |
Set the number of milliseconds since midnight, January 1st, 1970. | |
public override | toString(locale: String): String |
Return a string containing the date according to the locale. | |
public | toTimeString(): String |
Return a string containing the time portion of the date according to the locale. | |
public | toUTCString(): String |
Return a string containing the date according to the locale. | |
public | valueOf(): String |
Return the value of the object. | |
public get | year(): Number |
Return the current year as two digits. | |
public set | year(year: Number): Void |
Set the current year as two digits according to the locale. |
Method Detail
Construct a new date object.
- Description
- Permissible constructor forms:
- Date()
- Date(milliseconds)
- Date(dateString)
- Date(year, month, date)
- Date(year, month, date, hour, minute, second, msec)
Return the day of the month.
- Returns
- Returns the day of the year (1-31).
Return the day of the week in local time.
- Returns
- The integer day of the week (0 - 6, where 0 is Sunday).
Return the day of the year in local time.
- Returns
- The integer day of the year (0 - 366).
- Specified
- Ejs-11.
Time in milliseconds since the date object was constructed.
Return a formatted date string of the date.
- Description
- This corresponds to the C language strftime conventions. The format specifiers are:
- %A national representation of the full weekday name.
- %a national representation of the abbreviated weekday name.
- %B national representation of the full month name.
- %b national representation of the abbreviated month name.
- %C (year / 100) as decimal number; single digits are preceded by a zero.
- %c national representation of time and date.
- %D is equivalent to ``%m/%d/%y''.
- %d the day of the month as a decimal number (01-31).
- %E* %O* POSIX locale extensions. The sequences %Ec %EC %Ex %EX %Ey %EY %Od %Oe %OH %OI %Om %OM %OS %Ou %OU %OV %Ow %OW %Oy are supposed to provide alternate representations. Additionly %OB implemented to represent alternative months names (used standalone, without day mentioned).
- %e the day of month as a decimal number (1-31); single digits are preceded by a blank.
- %F is equivalent to ``%Y-%m-%d''.
- %G a year as a decimal number with century. This year is the one that contains the greater part of the week (Monday as the first day of the week).
- %g the same year as in ``%G'', but as a decimal number without century (00-99).
- %H the hour (24-hour clock) as a decimal number (00-23).
- %h the same as %b.
- %I the hour (12-hour clock) as a decimal number (01-12).
- %j the day of the year as a decimal number (001-366).
- %k the hour (24-hour clock) as a decimal number (0-23); single digits are preceded by a blank.
- %l the hour (12-hour clock) as a decimal number (1-12); single digits are preceded by a blank.
- %M the minute as a decimal number (00-59).
- %m the month as a decimal number (01-12).
- %m the month as a decimal number (01-12).
- %n a newline.
- %O* the same as %E*..
- %p national representation of either "ante meridiem" or "post meridiem" as appropriate.
- %R is equivalent to ``%H:%M''.
- %r is equivalent to ``%I:%M:%S %p''.
- %S the second as a decimal number (00-60).
- %s the number of seconds since the Epoch, UTC (see mktime(3)).
- %T is equivalent to ``%H:%M:%S''.
- %t a tab.
- %U the week number of the year (Sunday as the first day of the week) as a decimal number (00-53).
- %u the weekday (Monday as the first day of the week) as a decimal number (1-7).
- %V the week number of the year (Monday as the first day of the week) as a decimal number (01-53). If the week containing January 1 has four or more days in the new year, then it is week 1; otherwise it is the last week of the previous year, and the next week is week 1.
- %v is equivalent to ``%e-%b-%Y''.
- %W the week number of the year (Monday as the first day of the week) as a decimal number (00-53).
- %w the weekday (Sunday as the first day of the week) as a decimal number (0-6).
- %X national representation of the time.
- %x national representation of the date.
- %Y the year with century as a decimal number.
- %y the year without century as a decimal number (00-99).
- %Z the time zone name.
- %z the time zone offset from UTC; a leading plus sign stands for east of UTC, a minus sign for west of UTC, hours and minutes follow with two digits each and no delimiter between them (common form for RFC 822 date headers).
- %+ national representation of the date and time (the format is similar to that produced by date(1)).
- %% Literal percent.
- Parameters
layout: String Format layout.
- Returns
- String representation of the date.
- Specified
- Ejs-11.
Return the year as four digits.
- Returns
- The year.
Set the year as four digits according to the locale.
- Parameters
year: Number Year to set.
Return the day of the month.
- Returns
- Returns the day of the year (1-31).
Return the day of the week in local time.
- Returns
- The integer day of the week (0 - 6, where 0 is Sunday).
Return the year as four digits.
- Returns
- The integer year.
Return the hour (0 - 23) in local time.
- Returns
- The integer hour of the day.
Return the millisecond (0 - 999) in local time.
- Returns
- The number of milliseconds as an integer.
Return the minute (0 - 59) in local time.
- Returns
- The number of minutes as an integer.
Return the month (1 - 12) in local time.
- Returns
- The month number as an integer.
Return the second (0 - 59) in local time.
- Returns
- The number of seconds as an integer.
Return the number of milliseconds since midnight, January 1st, 1970.
- Returns
- The number of milliseconds as a long.
Return the number of minutes between the local computer time and Coordinated Universal Time.
- Returns
- The number of minutes as an integer.
Return the current hour (0 - 23) in local time.
- Returns
- The integer hour of the day TODO - should this be hour? for consistency with day.
Set the current hour (0 - 59) according to the locale.
- Parameters
Return the current millisecond (0 - 999) in local time.
- Returns
- The number of milliseconds as an integer.
Set the current millisecond (0 - 999) according to the locale.
- Parameters
Set the current minute (0 - 59) according to the locale.
- Parameters
Return the current minute (0 - 59) in local time.
- Returns
- The number of minutes as an integer.
Return the current month (0 - 11) in local time.
- Returns
- The month number as an integer.
Set the current month (0 - 11) according to the locale.
- Parameters
Time in nanoseconds since the date object was constructed.
Return a new Date object that is one day greater than this one.
- Parameters
inc: Number Increment in days to add (or subtract if negative)
- Returns
- A Date object.
- Specified
- Ejs-11.
Return the current time as milliseconds since Jan 1 1970.
Return the current second (0 - 59) in local time.
- Returns
- The number of seconds as an integer.
Set the current second (0 - 59) according to the locale.
- Parameters
Set the current millisecond (0 - 999) according to the locale.
- Parameters
Set the current minute (0 - 59) according to the locale.
- Parameters
Set the current month (0 - 11) according to the locale.
- Parameters
Set the current second (0 - 59) according to the locale.
- Parameters
msec: Number
Return the number of milliseconds since midnight, January 1st, 1970 and the current date object.
- Returns
- The number of milliseconds as a long.
Set the number of milliseconds since midnight, January 1st, 1970.
- Returns
- The number of milliseconds as a long.
Return a string containing the date according to the locale.
- Description
- Sample format: "Fri, 15 Dec 2006 23:45:09 GMT-0800".
- Parameters
locale: String
- Returns
- A string representing the date.
Return a string containing the time portion of the date according to the locale.
- Description
- Sample format: "23:45:09 GMT-0800".
- Returns
- A string representing the time.
Return a string containing the date according to the locale.
- Description
- Sample format: "Sat, 16 Dec 2006 08:06:21 GMT".
- Returns
- A string representing the date.
Return the value of the object.
- Returns
- This object.
Return the current year as two digits.
- Returns
- The integer year.
Set the current year as two digits according to the locale.
- Parameters
year: Number Year to set.