0

我想知道谁来计算asp中的天数、小时数和分钟数差异。因为我是新手,所以对我来说有点困难。这是我的代码

<%

Dim cdate, ddate

cdate = "9/27/2013 4:35:00 PM"

ddate = "9/30/2013 9:35:00 PM"


%>

请问我如何找到这两个日期之间的差异。还剩几天,还剩几小时,还剩几分钟

4

1 回答 1

1

Use DateDiff:

fromDate="31-Jan-09 00:00:00"
toDate="31-Jan-10 23:59:00"

document.write(DateDiff("yyyy",fromDate,toDate) & "<br />")
document.write(DateDiff("q",fromDate,toDate) & "<br />")
document.write(DateDiff("m",fromDate,toDate) & "<br />")
document.write(DateDiff("y",fromDate,toDate) & "<br />")
document.write(DateDiff("d",fromDate,toDate) & "<br />")
document.write(DateDiff("w",fromDate,toDate) & "<br />")
document.write(DateDiff("ww",fromDate,toDate) & "<br />")
document.write(DateDiff("h",fromDate,toDate) & "<br />")
document.write(DateDiff("n",fromDate,toDate) & "<br />")
document.write(DateDiff("s",fromDate,toDate) & "<br />")

see this link for the documentation: http://www.w3schools.com/vbscript/func_datediff.asp

于 2013-09-28T06:41:22.097 回答