ositcom Posted August 30, 2012 Share Posted August 30, 2012 Hello, I have been stuck in this issue for 3 days now, I have datetime records in a mysql table, I need a php clock which naturally counts down, I mean acts like a clock, but the clock time should be the datetime field value descending by the second, based on the full datetime, from year to seconds It is not just one record, I made it to display this clock, the problem is javascript, which makes all the 36 records the last record value, it is an ajax pagination, so i will need to do the same on second page, right now ajax is not a prioritty, I can let go of ajax pagination, but need to display the clock Help is appreciated Many Thanks Quote Link to comment https://forums.phpfreaks.com/topic/267822-need-a-php-clock-based-on-mysql-datetime/ Share on other sites More sharing options...
xyph Posted August 30, 2012 Share Posted August 30, 2012 What have you tried up to now? Quote Link to comment https://forums.phpfreaks.com/topic/267822-need-a-php-clock-based-on-mysql-datetime/#findComment-1373980 Share on other sites More sharing options...
ositcom Posted August 30, 2012 Author Share Posted August 30, 2012 I have tried this files I am attaching 18932_.php 18933_.php 18934_.php Quote Link to comment https://forums.phpfreaks.com/topic/267822-need-a-php-clock-based-on-mysql-datetime/#findComment-1373995 Share on other sites More sharing options...
ositcom Posted August 30, 2012 Author Share Posted August 30, 2012 Can you tell me how to convert php timestamp to javascript new date() Quote Link to comment https://forums.phpfreaks.com/topic/267822-need-a-php-clock-based-on-mysql-datetime/#findComment-1374023 Share on other sites More sharing options...
Barand Posted August 30, 2012 Share Posted August 30, 2012 Would that be a unix time value (1346359165) or a mysql timestamp (2012-08-30 21:40:30)? Quote Link to comment https://forums.phpfreaks.com/topic/267822-need-a-php-clock-based-on-mysql-datetime/#findComment-1374067 Share on other sites More sharing options...
ositcom Posted August 31, 2012 Author Share Posted August 31, 2012 unix time value (1346359165) 18940_.txt 18941_.txt 18942_.txt 18943_.txt Quote Link to comment https://forums.phpfreaks.com/topic/267822-need-a-php-clock-based-on-mysql-datetime/#findComment-1374298 Share on other sites More sharing options...
scootstah Posted August 31, 2012 Share Posted August 31, 2012 Can you tell me how to convert php timestamp to javascript new date() Second result on Google Syntax new Date() new Date(milliseconds) new Date(dateString) new Date(year, month, day [, hour, minute, second, millisecond]) So, as you can see, Date() will accept milliseconds. A UNIX timestamp is in seconds. So, multiply UNIX timestamp by 1000 and you have your milliseconds. <?php echo '<script>var date = new Date(1346359165 * 1000);</script>'; Quote Link to comment https://forums.phpfreaks.com/topic/267822-need-a-php-clock-based-on-mysql-datetime/#findComment-1374302 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.