strtotime - PHP Date from string -
i have specific date format need convert normal looking date.
strtotime()
isnt parsing correctly.
$fulldate = 'tue feb 04 2014 09:30:00 gmt-0800 (pacific standard time)'; echo $fulldate.'<br />'; echo strtotime($fulldate).'<br />'; echo date('y-m-d g:i a', strtotime($fulldate));
any ideas?
you can use datetime object:
<?php $fulldate = 'tue feb 04 2014 09:30:00 gmt-0800 (pacific standard time)'; //remove between brackets $datestring = preg_replace("/\([^)]+\)/","",$fulldate); //now, date object $date = new datetime($datestring); echo $date->format('y-m-d h:i:s'); ?>
try fiddle here: http://ideone.com/odwtuh
Comments
Post a Comment