If I have hours in the following format : 2:30 am how can I turn it into : 14:30:00
and if I got the date 2013-07-17 and the time 14:30:00 how can I turn it to a datatimestamp ? for example this will produce : 1374053400
thanks.
If I have hours in the following format : 2:30 am how can I turn it into : 14:30:00
and if I got the date 2013-07-17 and the time 14:30:00 how can I turn it to a datatimestamp ? for example this will produce : 1374053400
thanks.
am is before noon, not after..
This is what I would do:
$timeString = '2:30 am';
$dateString = '2013-07-17';
$timeZone = new DateTimeZone('Europe/London');
$date = new DateTime($dateString . ' ' . $timeString, $timeZone);
echo $date->format('H:i:s'); // 02:30:00
echo $date->getTimestamp(); // the timestamp as int
Have you tried to search in this site? :)
The second question has a really-similar one here: How to convert date to timestamp in PHP?
As for the first one, the answer is in the official php documentation: http://php.net/manual/es/function.date.php