phpretard Posted October 4, 2010 Share Posted October 4, 2010 I need to compare current time to data based time. Time in the database is in this format > 00:00:00 Easy enough. >>>>What I need is to convert "00:00:00" format into "time();" format<<<< The opposite is below...it's all I could come up with so far. <? $gettime = time(); $displayTime = date('H:i:s', time()); echo $displayTime; ?> Thank you. Link to comment https://forums.phpfreaks.com/topic/215118-time-only-conversion/ Share on other sites More sharing options...
AbraCadaver Posted October 4, 2010 Share Posted October 4, 2010 I need to compare current time to data based time. Time in the database is in this format > 00:00:00 Easy enough. >>>>What I need is to convert "00:00:00" format into "time();" format<<<< The opposite is below...it's all I could come up with so far. <? $gettime = time(); $displayTime = date('H:i:s', time()); echo $displayTime; ?> Thank you. time() format is a timestamp in seconds so you can build a timestamp that is the specified time for today and compare those: $databaseTime = strtotime('06:30:00'); // or whatever, just use strtotime() on it $displayTime = time(); if($databaseTime > $displayTime) { echo 'db time is greater'; elseif($databaseTime < $displayTime) { echo 'current time is greater'; } else { echo 'the times are equal'; } Link to comment https://forums.phpfreaks.com/topic/215118-time-only-conversion/#findComment-1118992 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.