cooldude832 Posted October 26, 2007 Share Posted October 26, 2007 Is there an easy way to take a date and convert it to a time stamp. In the format of September 12, 2001 - 05:00 pm ??? I know I can explode it and so forth, but is their easier Quote Link to comment https://forums.phpfreaks.com/topic/74817-textual-date-to-unix-timestap/ Share on other sites More sharing options...
teng84 Posted October 26, 2007 Share Posted October 26, 2007 $date=date_parse("2006-12-12 10:00:00"); echo date("M-d-Y H:i:s A",mktime($date['hour'],$date['minute'],$date['second'],$date['month'],$date['day'],$date['year'])); maybe Quote Link to comment https://forums.phpfreaks.com/topic/74817-textual-date-to-unix-timestap/#findComment-378325 Share on other sites More sharing options...
MadTechie Posted October 26, 2007 Share Posted October 26, 2007 LOL, explode seams less of a pain after seeing that Quote Link to comment https://forums.phpfreaks.com/topic/74817-textual-date-to-unix-timestap/#findComment-378326 Share on other sites More sharing options...
teng84 Posted October 26, 2007 Share Posted October 26, 2007 LOL, explode seams less of a pain after seeing that same pain i guess Quote Link to comment https://forums.phpfreaks.com/topic/74817-textual-date-to-unix-timestap/#findComment-378329 Share on other sites More sharing options...
PHP_PhREEEk Posted October 26, 2007 Share Posted October 26, 2007 Is the date coming from MySQL? If so, there are much easier ways of doing this... PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/74817-textual-date-to-unix-timestap/#findComment-378330 Share on other sites More sharing options...
Barand Posted October 26, 2007 Share Posted October 26, 2007 strtotime will handle some textual dates, unfortunately not that one This works <?php $dt = '12 September 2001 05:00 pm'; echo date ('Y-m-d H:i:s', strtotime($dt)); //--> 2001-09-12 17:00:00 ?> Quote Link to comment https://forums.phpfreaks.com/topic/74817-textual-date-to-unix-timestap/#findComment-378331 Share on other sites More sharing options...
teng84 Posted October 26, 2007 Share Posted October 26, 2007 strtotime will handle some textual dates, unfortunately not that one This works <?php $dt = '12 September 2001 05:00 pm'; echo date ('Y-m-d H:i:s', strtotime($dt)); //--> 2001-09-12 17:00:00 ?> sorry heres how i understand cooldude 2001-09-12 17:00:00 ->12 September 2001 05:00 pm am i stupid Quote Link to comment https://forums.phpfreaks.com/topic/74817-textual-date-to-unix-timestap/#findComment-378333 Share on other sites More sharing options...
marcus Posted October 26, 2007 Share Posted October 26, 2007 Those smilies make you look stupid, haha. Quote Link to comment https://forums.phpfreaks.com/topic/74817-textual-date-to-unix-timestap/#findComment-378334 Share on other sites More sharing options...
per1os Posted October 26, 2007 Share Posted October 26, 2007 I am unsure if this will work, but maybe just removing the "-" would make it work? $time = 'September 12, 2001 - 05:00 pm'; $time = str_replace("- ", "", $time); $timestamp = strtotime($time); echo date('Y-m-d h:i:s', $timestamp); Again I do not know if it will work or not, but give it a try. Quote Link to comment https://forums.phpfreaks.com/topic/74817-textual-date-to-unix-timestap/#findComment-378338 Share on other sites More sharing options...
Barand Posted October 26, 2007 Share Posted October 26, 2007 I am unsure if this will work, but maybe just removing the "-" would make it work? $time = 'September 12, 2001 - 05:00 pm'; $time = str_replace("- ", "", $time); $timestamp = strtotime($time); echo date('Y-m-d h:i:s', $timestamp); Again I do not know if it will work or not, but give it a try. Yes, it works Quote Link to comment https://forums.phpfreaks.com/topic/74817-textual-date-to-unix-timestap/#findComment-378340 Share on other sites More sharing options...
teng84 Posted October 26, 2007 Share Posted October 26, 2007 Those smilies make you look stupid, haha. does it affect your life? mind yours? I'MNOT ASKING FOR YOUR OPINION i love smilies Quote Link to comment https://forums.phpfreaks.com/topic/74817-textual-date-to-unix-timestap/#findComment-378343 Share on other sites More sharing options...
cooldude832 Posted October 26, 2007 Author Share Posted October 26, 2007 strtotime is the function I was seeking, I realized it and then got involved with it, needless to say I came to the same answer as you did. Quote Link to comment https://forums.phpfreaks.com/topic/74817-textual-date-to-unix-timestap/#findComment-378368 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.