Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with getting todays date/time and add 48 hours

    Hi everyone...

    I'm new here

    So, I have this script that basically countdowns to a specific date.

    Code:
    <script>
    	jQuery(document).ready(function(){
    		jQuery("#DIV_TO_PLACE_COUNTDOWN").jCountdown({
    			timeText:"2020/01/01 00:00:00",
    			
    		});
    	});
    </script>
    What I want to do, is to make the timeText dynamic.
    So I can set it to countdown to 12pm two days from now.

    I've been doing a little PHP programming in the past and my thoughts were that I could somehow grab todays date and then add +2 to it. Then I could somehow put that variable in there instead of the date.

    Something like this:

    timeText:"2020/01/(new date variable here) 00:00:00",

    Can you guys help me out

    - Hjalte

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    To make the date accurate, calculate the date from the server via PHP and then insert that date to the javascript.
    PHP Code:
    <?php
    $calculatedDate 
    = ...
    ?>
    <script>
    jQuery("#DIV_TO_PLACE_COUNTDOWN").jCountdown({
        timeText: "<?php echo $calculatedDate?>"
    });
    </script>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •