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 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 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 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 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 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 ?> 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 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. 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. 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 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 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. 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
Archived
This topic is now archived and is closed to further replies.