Jump to content

Recommended Posts

I have a variable get by php from table in database: $time,  06-10-2013 13:24:32

I wan't to echo in browser a $time decreased automtically, 13:24:32, 13:24:31, 13:24:30 ...

and when the time is time out, 00:00:00, the code will do some PHP functions.

Hope you understand and help me

Thanks in advanced.

Link to comment
https://forums.phpfreaks.com/topic/282750-decrease-time-with-javascript/
Share on other sites

If you want something to happen after a certain time, you don't want to rely on client side detection of the end.  Ignoring the  possibility of someone simply changing it to zero, if nobody triggers it, it would fail as well.  You should give what Irate said a shot, using cronjobs.  This way the server checks periodically if the time is up and triggers whatever to happen.   Nobody can cheat it, and you rely on nobody but yourself.

 

If you set an explicit time, be sure to pay attention to the timezone set on the server.

I guess I read the question differently. Are you trying to show the user a count-down? Something like: "This offer expires in 1 hour 12 minutes 32 seconds" -- Or are you trying to have some task performed at, say, midnight on Sunday?

 

For the later, a cron job is the way to go for the reasons stated by others.

 

For the former, we probably need a little more information; but JavaScript and AJAX are the direction to start.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.