Answer the question
In order to leave comments, you need to log in
How to easily parse unix_timestamp time beyond 24 hours in PHP?
The time can be 12h and 48h and 123h and it can be written both with minutes and seconds, for example: 72h 38m The strtotime
function does not accept such a format, it just produces a void. Maybe there is some standard way to parse time in unix_timestamp?
Answer the question
In order to leave comments, you need to log in
$time = '123h 5 m 07s';
if (preg_match('~(\d+)\s*h~', $time, $match)
$hours = $match[1];
if (preg_match('~(\d+)\s*m~', $time, $match)
$minutes = $match[1];
if (preg_match('~(\d+)\s*s~', $time, $match)
$seconds = $match[1];
If you solve your problem with regular expressions, then you have 2 problems.
Parse your data using regular expressions for seconds, minutes, and hours in s/m/h respectively. After that collect the timestamp with mktime .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question