chowderrunnah Posted February 7, 2015 Share Posted February 7, 2015 I have a online database with a column called consoles. Inside that, I have 2 rows called time and expire, I want to take the expire colum and minus it from the time now to tell them how long they have left online. I also have another column called cpukey, this is for when they type in something, it checks the cpukey column and does their information. I have something like this so far : http://gyazo.com/40feb904fc933a4d6b8392e99392c4bb , but it just displays the key again, I need it to take away the expire column by the time now. Anyone help me I would be really thankfull. Link to comment https://forums.phpfreaks.com/topic/294443-how-would-i-get-the-expire-colum-from-my-database-and-take-it-away-from-the-time-now-to-display-how-long-they-have-left/ Share on other sites More sharing options...
Barand Posted February 7, 2015 Share Posted February 7, 2015 Use TIMEDIFF() function EG mysql> SELECT TIMEDIFF('2015-02-07 18:00:00', NOW()) as time_remain; +-------------+ | time_remain | +-------------+ | 02:53:29 | +-------------+ Link to comment https://forums.phpfreaks.com/topic/294443-how-would-i-get-the-expire-colum-from-my-database-and-take-it-away-from-the-time-now-to-display-how-long-they-have-left/#findComment-1505147 Share on other sites More sharing options...
chowderrunnah Posted February 7, 2015 Author Share Posted February 7, 2015 Use TIMEDIFF() function EG mysql> SELECT TIMEDIFF('2015-02-07 18:00:00', NOW()) as time_remain; +-------------+ | time_remain | +-------------+ | 02:53:29 | +-------------+ so how would I set it out ? mysql> SELECT TIMEDIFF('2015-02-07 18:00:00', NOW()) as time_remain; what is this table called or do I need to create a new table ? Link to comment https://forums.phpfreaks.com/topic/294443-how-would-i-get-the-expire-colum-from-my-database-and-take-it-away-from-the-time-now-to-display-how-long-they-have-left/#findComment-1505148 Share on other sites More sharing options...
Barand Posted February 7, 2015 Share Posted February 7, 2015 I don't know what the table is called. It's your table. I am just showing how to subtract the current time from another and get the result SELECT TIMEDIFF(expire, NOW()) as time_remain FROM whateveryourtableiscalled Link to comment https://forums.phpfreaks.com/topic/294443-how-would-i-get-the-expire-colum-from-my-database-and-take-it-away-from-the-time-now-to-display-how-long-they-have-left/#findComment-1505150 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.