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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -