Possible Duplicate:
PHP: Convert uncommon date format to timestamp in most efficient manner possible?
How to convert this string to datetime format? 06/Oct/2011:19:00:02
I tried this but it doesn't work.
$s = '06/Oct/2011:19:00:02';
$date = strtotime($s);
echo date('d/M/Y:H:i:s', $date);
Use DateTime::createFromFormat
$date = date_create_from_format('d/m/Y:H:i:s', $s);
$date->getTimestamp();
The Problem is with your code formatting,
inorder to use strtotime()
You should replace '06/Oct/2011:19:00:02'
with 06/10/2011 19:00:02
and date('d/M/Y:H:i:s', $date);
with date('d/M/Y H:i:s', $date);
. Note the spaces in between.
So the final code looks like this
$s = '06/10/2011 19:00:02';
$date = strtotime($s);
echo date('d/M/Y H:i:s', $date);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With