Count Down to a particular date with ASP

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

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

The Result is: 

According to the system time of: 10/11/2024 4:47:34 PM

There are 81 Days, 7 Hours, 12 Minutes, 25 Seconds left until the year 2025.


asp countdown ADO VBScript tutorial authoring


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