How can I convert this string 05/Feb/2010:14:00:01
to unixtime ?
$d="05/Feb/2010:14:00:01";
$dr= date_create_from_format('d/M/Y:H:i:s', $d);
echo $dr->format('Y-m-d H:i:s');
here you get date string, give format specifier in ->format() according to format needed
Use the strtotime
function:
Example:
$date = "25 december 2009";
$my_date = date('m/d/y', strtotime($date));
echo $my_date;
If it's a string that you trust meaning that you have checked it before hand then the following would also work.
$date = new DateTime('2015-03-27');
http://www.php.net/date_parse_from_format
You should look into the strtotime() function.
Simple exploding should do the trick:
$monthNamesToInt = array('Jan'=>1,'Feb'=>2, 'Mar'=>3 /*, [...]*/ );
$datetime = '05/Feb/2010:14:00:01';
list($date,$hour,$minute,$second) = explode(':',$datetime);
list($day,$month,$year) = explode('/',$date);
$unixtime = mktime((int)$hour, (int)$minute, (int)$second, $monthNamesToInt[$month], (int)$day, (int)$year);