Date Object Methods
日期对象方法
FF: Firefox, N: Netscape, IE: Internet Explorer
FF:火狐,N:网景,IE
Method
方法Description
描述FFNIE
Date() Returns today's date and time
返回今天的日期和时间
getDate() Returns the day of the month from a Date object (from 1-31)
返回月中的第几天(1到31)
getDay() Returns the day of the week from a Date object (from 0-6)
返回一周中的第几天(0到6)
getMonth() Returns the month from a Date object (from 0-11)
返回月份数(0到11)
getFullYear() Returns the year, as a four-digit number, from a Date object
返回完整的年份数
getYear() Returns the year, as a two-digit or a four-digit number, from a Date object. Use getFullYear() instead !!
返回年份,可以是两位的或是四位的
getHours() Returns the hour of a Date object (from 0-23)
返回日期对象的小时数(0到23)
getMinutes() Returns the minutes of a Date object (from 0-59)
返回日期对象的分钟(0到59)
getSeconds() Returns the seconds of a Date object (from 0-59)
返回日期对象的秒(0到59)
getMilliseconds() Returns the milliseconds of a Date object (from 0-999)
返回毫秒(0到999)
getTime() Returns the number of milliseconds since midnight Jan 1, 1970
从1970年1月1号午夜到现在一共花去的毫秒数
getTimezoneOffset() Returns the difference in minutes between local time and Greenwich Mean Time (GMT)
本地时间和GMT相差多少分钟
getUTCDate() Returns the day of the month from a Date object according to universal time (from 1-31)
依据国际时间来得到月中的第几天(1到31)
getUTCDay() Returns the day of the week from a Date object according to universal time (from 0-6)
依据国际时间来得到现在是星期几(0到6)
getUTCMonth() Returns the month from a Date object according to universal time (from 0-11)
依据国际时间来得到月份(0到11)
getUTCFullYear() Returns the four-digit year from a Date object according to universal time
依据国际时间来得到完整的年份
getUTCHours() Returns the hour of a Date object according to universal time (from 0-23)
依据国际时间来得到小时(0-23)
getUTCMinutes() Returns the minutes of a Date object according to universal time (from 0-59)
依据国际时间来返回分钟(0到59)
getUTCSeconds() Returns the seconds of a Date object according to universal time (from 0-59)
依据国际时间来返回秒(0到59)
getUTCMilliseconds() Returns the milliseconds of a Date object according to universal time (from 0-999)
依据国际时间来返回毫秒(0到999)
parse() Takes a date string and returns the number of milliseconds since midnight of January 1, 1970
或得并返回自1970年1月1号凌晨到现在一共花掉了多少毫秒
setDate() Sets the day of the month in a Date object (from 1-31)
设置日
setMonth() Sets the month in a Date object (from 0-11)
设置月
setFullYear() Sets the year in a Date object (four digits)
设置年份
setYear() Sets the year in the Date object (two or four digits). Use setFullYear() instead !!
用setFullYear()来取代
setHours() Sets the hour in a Date object (from 0-23)
设置小时
setMinutes() Set the minutes in a Date object (from 0-59)
设置分钟
setSeconds() Sets the seconds in a Date object (from 0-59)
设置秒
setMilliseconds() Sets the milliseconds in a Date object (from 0-999)
设置毫秒
setTime() Calculates a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970 1 2 3
setUTCDate() Sets the day of the month in a Date object according to universal time (from 1-31)
依据国际时间来设置日期
setUTCMonth() Sets the month in a Date object according to universal time (from 0-11)
依据国际时间来设置月
setUTCFullYear() Sets the year in a Date object according to universal time (four digits)
依据国际时间来设置年份
setUTCHours() Sets the hour in a Date object according to universal time (from 0-23)
依据国际时间来设置小时
setUTCMinutes() Set the minutes in a Date object according to universal time (from 0-59)
依据国际时间来设置分钟
setUTCSeconds() Set the seconds in a Date object according to universal time (from 0-59)
依据国际时间来设置秒
setUTCMilliseconds() Sets the milliseconds in a Date object according to universal time (from 0-999)
依据国际时间来设置毫秒
toSource() Represents the source code of an object
显示对象的源代码
toString() Converts a Date object to a string
将日期对象转换为字符串
toGMTString() Converts a Date object, according to Greenwich time, to a string. Use toUTCString() instead !!
根据格林威治时间将Date[日期]对象转换为一个字符串。可以使用toUTCString()替代这种方法
toUTCString() Converts a Date object, according to universal time, to a string
根据通用时间将一个Date[日期]对象转换为一个字符串
toLocaleString() Converts a Date object, according to local time, to a string
根据本地时间将一个Date[日期]对象转换为一个字符串
UTC() Takes a date and returns the number of milliseconds since midnight of January 1, 1970 according to universal time
根据通用时间将日期计算为从1970年1月1日午夜至今所经过的时间(单位:毫秒)
valueOf() Returns the primitive value of a Date object
返回日期对象的原始值
分享到:
相关推荐
JavaScript之Date对象(源代码)JavaScript之Date对象(源代码)JavaScript之Date对象(源代码)JavaScript之Date对象(源代码)JavaScript之Date对象(源代码)JavaScript之Date对象(源代码)JavaScript之Date对象...
Date对象有个getDay方法,它根据本地时间,返回一个具体日期中一周的第几天。返回值从0~6,分别对应周日~周六 getDay 0 1 2 3 4 5 6 星期几 周日 周一 周二 周三 周四 周五 周六 用到日期相关的需求时...
2、Date对象常用方法 成员 作用 getFullYear() 获取表示年份的4位数字,如2020 setFullYear(value) 设置年份 getMonth() 获取月份,范围0~11(0表示一月,1表示二月,依次类推) setMonth(value) 设置月份 getDate()...
javascript中Date对象的getDay方法使用指南.docx
主要为大家详细介绍了JavaScript Date对象,介绍 Date 日期和时间对象的操作,感兴趣的小伙伴们可以参考一下
Date对象扩展,包括常用中文日期格式解析、加减操作、日期差、周操作和季操作。具体扩展的方法如下: parseCHS--静态方法。解析常用的中文日期并返回日期对象。 add--日期加减操作。[注:此函数在上传时还存在...
JavaScript Date(日期) 对象 日期对象用于处理日期和时间。 在线实例 使用 getFullYear() 获取年份。...我们提供 JavaScript Date 对象参考手册,其中包括所有可用于日期对象的属性和方法。JavaScript
web前端JavaScript DATE 用法思维导图,
很多时候,我们可以利用JavaScript中Date对象的内置方法来格式化,如: var d = new Date(); console.log(d); // 输出:Mon Nov 04 2013 21:50:33 GMT+0800 (中国标准时间) console.log(d.toDateString()); // 日期...
主要分享了JavaScript Date对象应用实例,获取日期时间,倒计时功能实现,限时抢购活动,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
javascript中Date对象的使用总结.docx
JavaScript Date对象使用小例子: 运行结果: 总结: 1、尽管我们认为12月是第12个月份,但是JavaScript从0开始计算月份,所以月份11表示12月; 2、nowDate.setDate(33);javaScript知道在12月份没有33天,只有31...
主要介绍了JavaScript Date对象功能与用法,结合实例形式总结分析了JavaScript Date对象基本功能、用法及操作注意事项,需要的朋友可以参考下
Date对象的使用;JavaScript的内置对象;JavaScript的内置对象;JavaScript的内置对象;JavaScript的内置对象;JavaScript的内置对象;案例讲解;JavaScript的内置对象;JavaScript的内置对象;JavaScript的内置对象;...
javascript转换日期字符串为Date日期对象的方法.docx
Date手册 Date对象的方法分为2种形式:本地时间和UTC时间。同一个方法,一般都会有2种时间格式操作(方法名带UTC的,就是操作UTC时间),我们主要学习本地时间的操作。
一起来看看 JavaScript 中的日期对象 Date。 获取月份天数 // 获取月份天数 function getMonthDayCount(year, month) { return new Date(year, month, 0).getDate(); } console.log(getMonthDayCount(2017, 10)); ...
javascript中Date对象应用之简易日历实现.docx