Carbon Posted October 2, 2011 Share Posted October 2, 2011 Hi, how would I go about making a countdown to midnight that will auto reset each time it hits midnight. I would like it to use server time and it doesn't have to be live, can just change when the user refreshes. Link to comment https://forums.phpfreaks.com/topic/248264-countdown-to-midnight/ Share on other sites More sharing options...
joel24 Posted October 2, 2011 Share Posted October 2, 2011 use strtotime('12am') to get the unix timestamp for midnight, then minus the current from that $midnight = strtotime('12am'); $current=time(); $count=$midnight-$current; //convert seconds to hours etc have a look at this function to convert seconds to hours http://www.laughing-buddha.net/php/lib/sec2hms/ Link to comment https://forums.phpfreaks.com/topic/248264-countdown-to-midnight/#findComment-1274920 Share on other sites More sharing options...
Carbon Posted October 2, 2011 Author Share Posted October 2, 2011 use strtotime('12am') to get the unix timestamp for midnight, then minus the current from that $midnight = strtotime('12am'); $current=time(); $count=$midnight-$current; //convert seconds to hours etc have a look at this function to convert seconds to hours http://www.laughing-buddha.net/php/lib/sec2hms/ Thanks Link to comment https://forums.phpfreaks.com/topic/248264-countdown-to-midnight/#findComment-1274921 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.