Creates a new Date.
The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
The month as a number between 0 and 11 (January to December).
可选date: numberThe date as a number between 1 and 31.
可选hours: numberMust be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.
可选minutes: numberMust be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.
可选seconds: numberMust be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.
可选ms: numberA number from 0 to 999 that specifies the milliseconds.
静态 只读ONE_一日的毫秒数。
常量值为 24 * 60 * 60 * 1000,即 86,400,000 毫秒。
静态 只读ONE_一周的毫秒数。
常量值为 7 * ONE_DAY。
Converts a Date object to a string.
Converts a Date object to a string.
Converts a Date object to a number.
Converts a Date object to a string or number.
The strings "number", "string", or "default" to specify what primitive to return.
A number if 'hint' was "number", a string if 'hint' was "string" or "default".
返回在当前日期时间基础上加上指定时间段后的新 DateX 实例。
该方法会归一化传入的 DateXDuration,支持标准字段名及其常用别名
(如 year、mon、week、day、hour、min、sec、mill 等)。
计算按“年 → 月 → 日 → 时 → 分 → 秒 → 毫秒”的顺序依次应用。
需要增加的时间段。
增加后的新 DateX 实例;原实例不被修改。
Gets the day-of-the-month, using local time.
Gets the day of the week, using local time.
Gets the year, using local time.
Gets the hours in a date, using local time.
Gets the milliseconds of a Date, using local time.
Gets the minutes of a Date object, using local time.
Gets the month, using local time.
Gets the seconds of a Date object, using local time.
Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.
Gets the difference in minutes between Universal Coordinated Time (UTC) and the time on the local computer.
Gets the day-of-the-month, using Universal Coordinated Time (UTC).
Gets the day of the week using Universal Coordinated Time (UTC).
Gets the year using Universal Coordinated Time (UTC).
Gets the hours value in a Date object using Universal Coordinated Time (UTC).
Gets the milliseconds of a Date object using Universal Coordinated Time (UTC).
Gets the minutes of a Date object using Universal Coordinated Time (UTC).
Gets the month of a Date object using Universal Coordinated Time (UTC).
Gets the seconds of a Date object using Universal Coordinated Time (UTC).
Sets the numeric day-of-the-month value of the Date object using local time.
A numeric value equal to the day of the month.
Sets the year of the Date object using local time.
A numeric value for the year.
可选month: numberA zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified.
可选date: numberA numeric value equal for the day of the month.
Sets the hour value in the Date object using local time.
A numeric value equal to the hours value.
可选min: numberA numeric value equal to the minutes value.
可选sec: numberA numeric value equal to the seconds value.
可选ms: numberA numeric value equal to the milliseconds value.
Sets the milliseconds value in the Date object using local time.
A numeric value equal to the millisecond value.
Sets the minutes value in the Date object using local time.
A numeric value equal to the minutes value.
可选sec: numberA numeric value equal to the seconds value.
可选ms: numberA numeric value equal to the milliseconds value.
Sets the month value in the Date object using local time.
A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
可选date: numberA numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used.
Sets the seconds value in the Date object using local time.
A numeric value equal to the seconds value.
可选ms: numberA numeric value equal to the milliseconds value.
Sets the date and time value in the Date object.
A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT.
Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC).
A numeric value equal to the day of the month.
Sets the year value in the Date object using Universal Coordinated Time (UTC).
A numeric value equal to the year.
可选month: numberA numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied.
可选date: numberA numeric value equal to the day of the month.
Sets the hours value in the Date object using Universal Coordinated Time (UTC).
A numeric value equal to the hours value.
可选min: numberA numeric value equal to the minutes value.
可选sec: numberA numeric value equal to the seconds value.
可选ms: numberA numeric value equal to the milliseconds value.
Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC).
A numeric value equal to the millisecond value.
Sets the minutes value in the Date object using Universal Coordinated Time (UTC).
A numeric value equal to the minutes value.
可选sec: numberA numeric value equal to the seconds value.
可选ms: numberA numeric value equal to the milliseconds value.
Sets the month value in the Date object using Universal Coordinated Time (UTC).
A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
可选date: numberA numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used.
Sets the seconds value in the Date object using Universal Coordinated Time (UTC).
A numeric value equal to the seconds value.
可选ms: numberA numeric value equal to the milliseconds value.
返回在当前日期时间基础上减去指定时间段后的新 DateX 实例。
该方法将传入时间段的每个字段取反后调用 DateX.add 完成计算。
需要减少的时间段,类型与 DateX.add 的参数一致。
减少后的新 DateX 实例;原实例不被修改。
Returns a date as a string value.
Returns a date as a string value in ISO format.
返回用于 JSON 序列化的日期时间字符串。
默认调用 DateX.toString 并传入 "json" 模式,输出
YYYY-MM-DDTHH:MM:SS 格式。
JSON 序列化字符串。
Returns a date as a string value appropriate to the host environment's current locale.
Converts a date to a string by using the current or specified locale.
可选locales: string | string[]A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
可选options: DateTimeFormatOptionsAn object that contains one or more properties that specify comparison options.
Converts a date to a string by using the current or specified locale.
可选locales: LocalesArgumentA locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
可选options: DateTimeFormatOptionsAn object that contains one or more properties that specify comparison options.
Returns a value as a string value appropriate to the host environment's current locale.
Converts a date and time to a string by using the current or specified locale.
可选locales: string | string[]A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
可选options: DateTimeFormatOptionsAn object that contains one or more properties that specify comparison options.
Converts a date and time to a string by using the current or specified locale.
可选locales: LocalesArgumentA locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
可选options: DateTimeFormatOptionsAn object that contains one or more properties that specify comparison options.
Returns a time as a string value appropriate to the host environment's current locale.
Converts a time to a string by using the current or specified locale.
可选locales: string | string[]A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
可选options: DateTimeFormatOptionsAn object that contains one or more properties that specify comparison options.
Converts a time to a string by using the current or specified locale.
可选locales: LocalesArgumentA locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
可选options: DateTimeFormatOptionsAn object that contains one or more properties that specify comparison options.
将日期时间格式化为 YYYY-MM-DD HH:MM:SS 形式的字符串。
当传入 "json" 模式时,日期与时间之间使用 T 连接,以兼容 ISO 风格。
可选mode: "json"可选的格式化模式。传入 "json" 时使用 T 分隔符。
格式化后的日期时间字符串。
Returns a time as a string value.
Returns a date converted to a string using Universal Coordinated Time (UTC).
Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.
静态nowReturns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).
静态parseParses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970.
A date string
静态UTCReturns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date.
The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
The month as a number between 0 and 11 (January to December).
可选date: numberThe date as a number between 1 and 31.
可选hours: numberMust be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.
可选minutes: numberMust be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.
可选seconds: numberMust be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.
可选ms: numberA number from 0 to 999 that specifies the milliseconds.
Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date.
The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
可选monthIndex: numberThe month as a number between 0 and 11 (January to December).
可选date: numberThe date as a number between 1 and 31.
可选hours: numberMust be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.
可选minutes: numberMust be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.
可选seconds: numberMust be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.
可选ms: numberA number from 0 to 999 that specifies the milliseconds.
扩展
Date的日期时间运算类。DateX在原生Date基础上增加了 DateX.add 与 DateX.subtract 方法,支持按年、月、周、日、时、分、秒、 毫秒进行偏移计算。同时覆盖 DateX.toString 与 DateX.toJSON,输出统一的YYYY-MM-DD HH:MM:SS格式。添加于
26.4.13
参阅
DateXDuration
示例