Avatar of seopro
seopro asked on

A very simple "customizable" countdown script

Hello,
I'm looking for a very simple customizable countdown script.
By "customizable", I mean that I need to define the start and the end dates.
For example:
Start date:26/05/08
End date:26/06/08
I'd appreciate all your help!
Thanks in advance!
JavaScriptVB Script

Avatar of undefined
Last Comment
RobSampson

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
BrianGEFF719

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
RobSampson

This one is VBScript in an HTA.  Save the code into Notepad with an HTA extension.

Regards,

Rob.
<head>
<title>Countdown</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Countdown"
     BORDER="thin"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
</head>
<script language="VBScript">
' Declare global variable outside the Subs
Dim intSeconds, dteTo
 
Sub Window_onLoad
 intWidth = 640
 intHeight = 480
 Me.ResizeTo intWidth, intHeight
 Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
 
 dteTo = "25-Jul-2008 12:00:00 PM" 
 
 span_heading.innerHTML = "Countdown to " & dteTo
 intSecondsToDate = DateDiff("s", Now, CDate(dteTo))
 intDaysLeft = Int(intSecondsToDate \ 86400)
 intHoursLeft = Int((intSecondsToDate - (intDaysLeft * 86400)) \ 3600)
 intMinutesLeft = Int((intSecondsToDate - (intDaysLeft * 86400) - (intHoursLeft * 3600)) \ 60)
 intSecondsLeft = Int((intSecondsToDate - (intDaysLeft * 86400) - (intHoursLeft * 3600) - (intMinutesLeft * 60)))
 
 strHTML = intDaysLeft & " Days, " & intHoursLeft & " Hours, " & intMinutesLeft & " Minutes, " & intSecondsLeft & " Seconds"
 span_clock.innerHTML = strHTML
 
 iTimerID = window.setInterval("UpdateTimer", 1000)
End Sub
Sub UpdateTimer
 intSecondsToDate = DateDiff("s", Now, CDate(dteTo))
 intDaysLeft = Int(intSecondsToDate \ 86400)
 intHoursLeft = Int((intSecondsToDate - (intDaysLeft * 86400)) \ 3600)
 intMinutesLeft = Int((intSecondsToDate - (intDaysLeft * 86400) - (intHoursLeft * 3600)) \ 60)
 intSecondsLeft = Int((intSecondsToDate - (intDaysLeft * 86400) - (intHoursLeft * 3600) - (intMinutesLeft * 60)))
 
 strHTML = intDaysLeft & " Days, " & intHoursLeft & " Hours, " & intMinutesLeft & " Minutes, " & intSecondsLeft & " Seconds"
 span_clock.innerHTML = strHTML
End Sub
</script>
<body STYLE="font:14 pt arial; color:white;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')">
      <table width='90%' height = '100%' align='center' border='0'>
            <tr>
                  <td align="center" colspan="2">
                        <h2><span id="span_heading">Countdown to 25-Jul-2008 12:00:00 PM</h2></span>
                  </td>
            </tr>
            <tr>
                  <td align="center">
                        <font size="4"><span id="span_clock">
                        </span></font>
                  </td>
            </tr>
            <tr>
                  <td align="center">
                        <br><input type='button' value='Close' name='btnClose' id='btnClose' onClick='vbs:window.close'>
                  </td>
            </tr>
      </table>
</body>

Open in new window

ASKER
seopro

Hello,
Thanks for the useful link, BrianGEFF719!
RobSampson, Thanks for your code, But I was looking to put it on my website online, Not an HTA application.
But thanks anyway for all your help!
RobSampson

No problem.  If your web page supports VBScript, you can use the same code within it.  Otherwise, you could translate my code to Java and get it working....

Regards,

Rob.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23