Count Down to a particular date with ASP

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

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

The Result is: 

According to the system time of: 9/22/2017 8:12:11 PM

There are 100 Days, 3 Hours, 47 Minutes, 48 Seconds left until the year 2018.


asp countdown ADO VBScript tutorial authoring


Back To Top
© 1998 - 2017 psacake.com | My3C's

Version 7.2 | Advertise on this site