Forum Moderators: open

Message Too Old, No Replies

Using VBScript to countdown hours and minutes until tomorrow

         

midoriweb

11:23 am on Feb 2, 2007 (gmt 0)

10+ Year Member



Hey Everyone,

So I'm trying to write a script to countdown the number of hours and minutes until tomorrow. So far, this is what I have:

<%
response.write(dateDiff("h",now(),date+1)) & " hours and " & dateDiff("m",Time(),date+1) & " Minutes "
%>

The code above correctly displays the hours until tomorrow... but it's not displaying the minutes correctly. It's displaying the total minutes until tomorrow. If there at 4 hours left until tomorrow it's saying "4 Hours and 240 minutes."

I need it to display "4 hours and 0 minutes."

The best way I think this can be done is to take the current time in minutes and subtract that from 60. What you have left is the total minutes until the next hour.

So... can someone help me figure our how to take the current time in minutes and subtract that from 60?

makeupalley

10:39 am on Feb 3, 2007 (gmt 0)

10+ Year Member



Haven't tested but I think this shold work:

dateDiff("h",now(),date+1) & " hours and " & dateDiff("m",Time(),DateAdd("h",date+1,-1*dateDiff("h",now(),date+1))) & " Minutes "

midoriweb

11:57 am on Feb 4, 2007 (gmt 0)

10+ Year Member



Thank you MakeUpAlley,

I finally got it working! Thanks for the help :)