JS Date日期处理
获取当前日期:new Date() =======Fri Sep 29 2017 15:42:09 GMT+0800 (中国标准时间)
将日期转换为时间戳:1、Date(new Date()) 2、 +new Date() =======1506670951670
将时间戳转换成日期:new Date(1506670708000) ======Fri Sep 29 2017 15:38:28 GMT+0800 (中国标准时间)
JavaScript 日期获取方法:
var d = new Date();
d.getTime() 返回自 1970 年 1 月 1 日以来的毫秒数
d.getFullYear() 方法以四位数字形式返回日期年份
d.getMonth() 以数字(0-11)返回日期的月份:
d.getDate() 方法以数字(1-31)返回日期的日:
d.getHours() 方法以数字(0-23)返回日期的小时数:
d.getMinutes() 方法以数字(0-59)返回日期的分钟数:
d.getSeconds() 方法以数字(0-59)返回日期的秒数:
d.getMilliseconds() 方法以数字(0-999)返回日期的毫秒数:
d.getDay() 方法以数字(0-6)返回日期的星期名(weekday)