js加减日期

function DateDiff(asStartDate,asEndDate){

var miStart=Date.parse(asStartDate.replace(/\-/g,'/'));

var miEnd=Date.parse(asEndDate.replace(/\-/g,'/'));

return (miEnd-miStart)/(1000*24*3600);

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

parse
Returns the number of milliseconds in a date string since January 1, 1970, 00:00:00, local time.
方法源 Date
静态
实现版本 Navigator 2.0, LiveWire 1.0


语法
Date.parse(dateString)
参数
:
dateString A string representing a date.


描述
The parse method takes a date string (such as "Dec 25, 1995") and returns the number of milliseconds since January 1, 1970, 00:00:00 (local time). This function is useful for setting date values based on string values, for example in conjunction with the setTime method and the Date object.
Given a string representing a time, parse returns the time value. It accepts the IETF standard date语法: "Mon, 25 Dec 1995 13:30:00 GMT". It understands the continental US time-zone abbreviations, but for general use, use a time-zone offset, for example, "Mon, 25 Dec 1995 13:30:00 GMT+0430" (4 hours, 30 minutes west of the Greenwich meridian). If you do not specify a time zone, the local time zone is assumed. GMT and UTC are considered equivalent.

Because parse is a static method of Date, you always use it as Date.parse(), rather than as a method of a Date object you created.


示例
If IPOdate is an existing Date object, then you can set it to August 9, 1995 as follows:
IPOdate.setTime(Date.parse("Aug 9, 1995"))
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值