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. Quote 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/ Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/248264-countdown-to-midnight/#findComment-1274921 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.