0

I have a DATETIME date in a mysql field, and i'd like the simplest timer displayed on my PHP page counting down to that. The timer will never be over a few minutes.

I'm guessing some kind of javascript php hybrid is needed?

Eg "40 secs left"

Note: I know nothing about javascript, but half decent at PHP.

1
  • To your deleted question: You have forgotten $input = before your explode line :) Commented Oct 24, 2011 at 13:28

2 Answers 2

3

Take a look at Keith Woord's jQuery Countdown plugin. It is very easy to use and you can pass it your DATETIME on page load via PHP echo / print.

I hope this helps!

EDIT:

To implement this solution you could do the following:

<head>
...

<!-- Include jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function(){

    // Activate Countdown //   
    $('timerDiv').countdown({ 
        until: new Date(<?= $date ?>), // Date need to be in "YYYY, Start - End, M" Format like this: "2012, 8 - 1, 8"
        format: 'HMS' // H = Hours, M = Minutes, S = Seconds. Remove letter to omit it
    });
</script>

...
</head>
<body>
    <div id="timerDiv"></div>
</body>
Sign up to request clarification or add additional context in comments.

3 Comments

@user961882 is the DATETIME MySQL or Server based?
even the basics dont seem to work (that code above). I dont think my server supports new Date function or something. Im outta patience and energy lol I think i'll leave it.
@user961882 lol... been there. If there are specific errors that appear, or if you wanted to edit your OP with the code you are using, I'd be happy to take a look at it for you!
0

you can use jQuery Countdown for that, so you just need to provide a date in correct format described there

1 Comment

ive got the countdown running, but i cant seem to get a php date converted into js for it. Ive checked all the tutorials and nothing makes sense or works for me. stressed lol

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.