project3 Posted February 7, 2008 Share Posted February 7, 2008 what I have is time in 12 hour format. I want to turn it into a numeric value so I can do a > or < comparison. I am familiar on using mktime with 24 hour format. but with 12 hour format im not sure where you would put the am pm part in. I thought there was a time string to timestamp command in php but I cant seem to find what im looking for. Link to comment https://forums.phpfreaks.com/topic/89847-mktime-or-turn-time-into-number/ Share on other sites More sharing options...
kenrbnsn Posted February 7, 2008 Share Posted February 7, 2008 use the strtotime() function. <?php $date_str = '2008-02-03 3:00 PM'; $date_num = strtotime($date_str); ?> Ken Link to comment https://forums.phpfreaks.com/topic/89847-mktime-or-turn-time-into-number/#findComment-460448 Share on other sites More sharing options...
haku Posted February 7, 2008 Share Posted February 7, 2008 You can do this if you want to stick with unix timestamps (which I prefer) if($am_pm == 'am') { $hours = hours + 12; } Where $am_pm is a variable that either holds a value of AM or PM. You can use $hours in your mktime() equation from there. Link to comment https://forums.phpfreaks.com/topic/89847-mktime-or-turn-time-into-number/#findComment-460587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.