javascript Date object

构造

Date()

静态方法

方法描述
Date.now()返回时间戳
Date.parse()将字符串转换为时间戳
Date.UTC()

实例方法

方法描述
Date.prototype.getDate()Returns the day of the month (1–31) for the specified date according to local time.
Date.prototype.getDay()Returns the day of the week (0–6) for the specified date according to local time.
Date.prototype.getFullYear()Returns the year (4 digits for 4-digit years) of the specified date according to local time.
Date.prototype.getHours()Returns the hour (0–23) in the specified date according to local time.
Date.prototype.getMilliseconds()Returns the milliseconds (0–999) in the specified date according to local time.
Date.prototype.getMinutes()Returns the minutes (0–59) in the specified date according to local time.
Date.prototype.getMonth()Returns the month (0–11) in the specified date according to local time.
Date.prototype.getSeconds()Returns the seconds (0–59) in the specified date according to local time.
Date.prototype.getTime()Returns the numeric value of the specified date as the number of milliseconds since January 1, 1970, 00:00:00 UTC. (Negative values are returned for prior times.)
Date.prototype.getTimezoneOffset()Returns the time-zone offset in minutes for the current locale.
Date.prototype.getUTCDate()Returns the day (date) of the month (1–31) in the specified date according to universal time.
Date.prototype.getUTCDay()Returns the day of the week (0–6) in the specified date according to universal time.
Date.prototype.getUTCFullYear()Returns the year (4 digits for 4-digit years) in the specified date according to universal time.
Date.prototype.getUTCHours()Returns the hours (0–23) in the specified date according to universal time.
Date.prototype.getUTCMilliseconds()Returns the milliseconds (0–999) in the specified date according to universal time.
Date.prototype.getUTCMinutes()Returns the minutes (0–59) in the specified date according to universal time.
Date.prototype.getUTCMonth()Returns the month (0–11) in the specified date according to universal time.
Date.prototype.getUTCSeconds()Returns the seconds (0–59) in the specified date according to universal time.
Date.prototype.getYear()Returns the year (usually 2–3 digits) in the specified date according to local time. Use getFullYear() instead.
Date.prototype.setDate()Sets the day of the month for a specified date according to local time.
Date.prototype.setFullYear()Sets the full year (e.g. 4 digits for 4-digit years) for a specified date according to local time.
Date.prototype.setHours()Sets the hours for a specified date according to local time.
Date.prototype.setMilliseconds()Sets the milliseconds for a specified date according to local time.
Date.prototype.setMinutes()Sets the minutes for a specified date according to local time.
Date.prototype.setMonth()Sets the month for a specified date according to local time.
Date.prototype.setSeconds()Sets the seconds for a specified date according to local time.
Date.prototype.setTime()Sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC. Use negative numbers for times prior.
Date.prototype.setUTCDate()Sets the day of the month for a specified date according to universal time.
Date.prototype.setUTCFullYear()Sets the full year (e.g. 4 digits for 4-digit years) for a specified date according to universal time.
Date.prototype.setUTCHours()Sets the hour for a specified date according to universal time.
Date.prototype.setUTCMilliseconds()Sets the milliseconds for a specified date according to universal time.
Date.prototype.setUTCMinutes()Sets the minutes for a specified date according to universal time.
Date.prototype.setUTCMonth()Sets the month for a specified date according to universal time.
Date.prototype.setUTCSeconds()Sets the seconds for a specified date according to universal time.
Date.prototype.setYear()Sets the year (usually 2–3 digits) for a specified date according to local time. Use setFullYear() instead.
Date.prototype.toDateString()Returns the “date” portion of the Date as a human-readable string like ‘Thu Apr 12 2018’.
Date.prototype.toISOString()Converts a date to a string following the ISO 8601 Extended Format.
Date.prototype.toJSON()Returns a string representing the Date using toISOString(). Intended for use by JSON.stringify().
Date.prototype.toGMTString()Returns a string representing the Date based on the GMT (UTC) time zone. Use toUTCString() instead.
Date.prototype.toLocaleDateString()Returns a string with a locality sensitive representation of the date portion of this date based on system settings.
Date.prototype.toLocaleFormat()Converts a date to a string, using a format string.
Date.prototype.toLocaleString()返回当地习惯的时间格式,默认是美国格式 1999/10/20
Date.prototype.toLocaleTimeString()Returns a string with a locality-sensitive representation of the time portion of this date, based on system settings.
Date.prototype.toString()Returns a string representing the specified Date object. Overrides the Object.prototype.toString() method.
Date.prototype.toTimeString()Returns the “time” portion of the Date as a human-readable string.
Date.prototype.toUTCString()Converts a date to a string using the UTC timezone.
Date.prototype.valueOf()Returns the primitive value of a Date object. Overrides the Object.prototype.valueOf() method.

参考:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_dates
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值