使用asp.vb计算天数,小时数和分钟数

时间:2013-09-27 19:28:15

标签: asp-classic

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

<%

Dim cdate, ddate

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

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


%>

请问我如何找到这两个日期之间的差异。正好几天,剩余时间和剩余时间

1 个答案:

答案 0 :(得分:1)

使用 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 />")

请参阅此链接以获取文档: http://www.w3schools.com/vbscript/func_datediff.asp