hoangthi Posted October 6, 2013 Share Posted October 6, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/282750-decrease-time-with-javascript/ Share on other sites More sharing options...
Irate Posted October 6, 2013 Share Posted October 6, 2013 Cronjobs. Quote Link to comment https://forums.phpfreaks.com/topic/282750-decrease-time-with-javascript/#findComment-1452785 Share on other sites More sharing options...
codefossa Posted October 6, 2013 Share Posted October 6, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/282750-decrease-time-with-javascript/#findComment-1452788 Share on other sites More sharing options...
DavidAM Posted October 7, 2013 Share Posted October 7, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/282750-decrease-time-with-javascript/#findComment-1452987 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.