Count Down to a particular date with ASP

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

<%
CountdownDate = #1/1/2026 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 2026.
</BODY>
</HTML>

The Result is: 

According to the system time of: 1/20/2025 8:31:10 PM

There are 345 Days, 3 Hours, 28 Minutes, 49 Seconds left until the year 2026.


asp countdown ADO VBScript tutorial authoring


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