3

I can do with advise. I have the following table:

enter image description here

The date in top left hand corner is echoed from database.

I would like to add a countdown timer to match day, I have multiple games happening over multiple days.

I need to try and find a way to integrate the countdown timer using php or to pass the date value to my jquery script.

I am merely looking for logic or advise how to tackle this problem.

Thanks

KKL Michael
  • 795
  • 1
  • 13
  • 31
  • 1
    The answers under explain how to get a server-side value into a javascript variables. That said, be carefull when dealing with times on client-side. Although it's definitely the way to go, you may need to consider different timezones for your server and client time. Therefore I would suggest to calculate the time left server-side and just send that as a starting point to your javascript countdown. – Laurent S. May 08 '15 at 09:25

3 Answers3

0

Personally, I have split the time into hours/minutes/seconds and passed those separately to jQuery. In this example, I can define the minutes and seconds separately;

iMins = <?php define it here ?>,
iSecs = <?php define here ?>;

This example could be modified so that the countDown() function points to an element each time to run multiple timers.

Pudd
  • 449
  • 3
  • 13
0

You will want to echo the php variable into some sort of Javascript countdown timer using:

var dateInJavascript = '<?php echo($dateFromDatabase); ?>';

You could one of the many javascript countdown timers for example -

http://www.gieson.com/Library/projects/utilities/countdown/

Or you could implement this lovely stack post -

The simplest possible JavaScript countdown timer?

Community
  • 1
  • 1
0

Try to use this js function, its easy to make countdown timer:

https://github.com/aneeshikmat/timeDownCounter

example after include timeDownCounter.js:

timeDownCounter({
            'countDownIdSelector': 'time-down-counter',
            'countDownDate':  new Date("Sep 5, 2018 15:37:25").getTime(),
            'countDownResSperator': '-'
            'countDownReturnData': 'from-hours',
            'addSpanForResult': true,
            'addSpanForEachNum': true,
            'contDownOver': 'Time is expired, and you can say hello now :P',
            'getTemplateResult': 0
        }).startCountDown();
Mosa
  • 33
  • 8