日期相关

日期函数:
 new Date()
 new Date(milliseconds)
 new Date(datestring)
 new Date(year, month)
 new Date(year, month, day)
 new Date(year, month, day, hours)
 new Date(year, month, day, hours, minutes)
 new Date(year, month, day, hours, minutes, seconds)
 new Date(year, month, day, hours, minutes, seconds, microseconds)

getDay()函数 -- 返回date对象中的星期中的天数(0-6)

Date.parse() 函数 -- 解析一个日期的字符串,并返回该日期距1970年1月1日午夜之间的毫秒数(时间戳)
 
 
在chrome中使用,使用
new Date("20xx-xx-xx 00:00:00")
显示正常,但在IE中显示NaN,如果使用
new Date("20xx/xx/xx 00:00:00")
则可以解决兼容问题(chrome,IE,firefox,opera均测试正常

toLocaleString 谷歌还是欧美风格
valueOf返回毫秒数  parse也返回毫秒数

兼容办法
function NewDate(str) {
str = str.split('-'); 
var date = new Date();
date.setUTCFullYear(str[0], str[1] - 1, str[2]);
date.setUTCHours(0, 0, 0, 0);
return date;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值