JavaScript Countdown reset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deludeddonny
    New Member
    • Feb 2011
    • 1

    JavaScript Countdown reset

    Hi all,

    Please can someone help, I am a complete noob...

    I have this code, but it is not quiet right,

    Now the code below resets at 4, but I need it to reset at 8 pm
    I have tried to change the code but it doesnt seem to work, it also seems to do tomorrows time rather than todays time.

    Also would their be anyway so instead of saying: "and your order will be delivered tommrow" it could say "and your order will be delivered [tomorrows date i.e Wednesday 15th]"

    and instead of saying: "and your order will be delivered on Tuesday" it could say "and your order will be delivered on [Tuesdays date i.e Tuesday 19th]"

    I hope you understand what I am tryign to do...

    Code:
    <html>
    
    <head>
    
    <script type="text/javascript">
    function ord()
    {
    var c_t = 4;
    
    var dd = new Date();
    
    var ti_h = dd.getHours();
    
    var ti_m = dd.getMinutes();
    
    
    if(ti_h > c_t)
    {
    
    var di_t_h = ti_h - c_t;
    
    var di_t_mi = 60 - ti_m;
    
    var h = 24 - di_t_h;
    
    var mi = di_t_mi;
    
    var mess = h+"hours"+mi+"minutes";
    
    }
    
    
    
    var da = dd.getDay();
    
    //var da = document.getElementById("da").value;
    
    switch(da)
    {
    case 2:
    case 3:
    case 4:
    case 5:
    document.write("Place your order within the next "+mess+"and your order will be delivered tommrow");
    break;
    case 6:
    case 7:
    case 1:
    document.write("and your order will be delivered on Tuesday");
    break;
    }
    }
    
    ord();
    
    </script>
    
    </head>
    
    <body>
    
    </body>
    
    </html>
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    I don't know are there any java script functions allow it.
    But you can add some maths and build a logic to determine the date on next Tuesday. It should net be hard.

    Regards
    Dheeraj Joshi

    Comment

    Working...