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: 11/21/2024 1:57:30 AM

There are 40 Days, 22 Hours, 2 Minutes, 29 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