Count Down to a particular date with ASP

Here is a simple script that gives the amount of time remaining until the year 2024.

<%
CountdownDate = #1/1/2024 12:00:00AM#
If Date >= CountdownDate Then
    Response.Write "Happy New Year!"
    Response.End
End If

theDate     = Now
DaysLeft    = DateDiff("d",theDate,CountdownDate) - 1
theDate     = DateAdd("d",DaysLeft,theDate)
HoursLeft   = DateDiff("h",theDate,CountdownDate) - 1
theDate     = DateAdd("h",HoursLeft,theDate)
MinutesLeft = DateDiff("n",theDate,CountdownDate) - 1
theDate     = DateAdd("n",MinutesLeft,theDate)
SecondsLeft = DateDiff("s",theDate,CountdownDate) - 1
%>

<HTML>
<BODY>
According to the system time of: <%= Now %>
<p>
There are <%= DaysLeft%> Days, <%= HoursLeft %> Hours,
<%= MinutesLeft %> Minutes, <%= SecondsLeft %> Seconds
left until the year 2024.
</BODY>
</HTML>

The Result is: 

According to the system time of: 6/1/2023 9:28:03 PM

There are 213 Days, 2 Hours, 31 Minutes, 56 Seconds left until the year 2024.


asp countdown ADO VBScript tutorial authoring


Back To Top
© 1998 - 2023 psacake.com
Version 7.21 | Advertise on this site