我想了解Weekday
中特定Now
之前有多长时间。
我到处搜索,但找不到任何东西。
我认为我必须以某种方式使用DateDiff
- 函数和WeekDay
- 函数。
方案是:
我的变量varWeekDay
与星期几,例如:1/2/3/4/5/6/7
另一个变量varStartTime
,其中包含当天的时间:hh:mm
最后一个变量varStopTime
也是当天的时间:hh:mm
if varWeekday = Weekday(now, 2) and varStartTime < formatdatetime(now, 4) then
.... Write how long time till start in hours / minutes
elseif varWeekday = Weekday(now, 2) and varStartTime >= formatdatetime(now, 4) and varStopTime < formatdatetime(now, 4) then
response.write("Already started!")
else
.... Write how long time till start in days / hours / minutes
end if
“多长时间”可能是这样的:“从现在开始的2天3小时27分钟”
应从特定日期时间生成相同的输出。例如:06/08/2012 23:55是“从现在开始的1天13分钟”
我真的希望你们能帮忙! :)
答案 0 :(得分:1)
我没有完全理解你需要的开始时间和结束时间,但是这个脚本会告诉你现在和一周中某一天的开始之间有多少时间。
<%
Dim varNow : varNow = Now()
Dim varWeekday : varWeekday = 7 'This is the weekday to look for (1 is Sunday, 7 is Saturday)
'This next line sets the time to the start of the day
Dim varThisDate : varThisDate = DateSerial(Year(varNow), Month(varNow), Day(varNow))
Dim varThisWeekday
Do
varThisDate = DateAdd("d", 1, varThisDate)
varThisWeekday = Weekday(varThisDate)
If varThisWeekday = varWeekday Then
Exit Do
End If
Loop
'These next lines just convert and display the remaining time into the different units
Response.Write("Until next " & WeekdayName(varWeekday) & "<br />")
Dim varSeconds : varSeconds = DateDiff("s", varNow, varThisDate)
Dim varDays : varDays = Int(varSeconds / 60 / 60 / 24)
varSeconds = varSeconds - (varDays * 24 * 60 * 60)
Dim varHours : varHours = Int(varSeconds / 60 / 60)
varSeconds = varSeconds - (varHours * 60 * 60)
Dim varMinutes : varMinutes = Int(varSeconds / 60)
varSeconds = varSeconds - (varMinutes * 60)
Response.Write("Days: " & varDays & "<br />")
Response.Write("Hours: " & varHours & "<br />")
Response.Write("Minutes: " & varMinutes & "<br />")
Response.Write("Seconds: " & varSeconds & "<br />")
%>