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. Quote Link to comment 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'; } Quote Link to comment 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.