In our mikrotik
when we get user uptime, that's return a string such as "2d13m30s"
and i should convert it to second, this stirng can be "13m30s"
or "30s"
, i tired to convert it to second but i think there isn't standard php for that
i think in php
this function as strtotime
can't be help me to convert it to second and this code what i tested and gmdate
can convert second to time:
date("s",strtotime("2h2m30s"))
I see as per the question tags that you have Carbon installed so CarbonInterval
already handles that for you:
echo \Carbon\CarbonInterval::fromstring('2h2m30s') . "\n";
echo \Carbon\CarbonInterval::fromstring('2h2m30s')->totalSeconds . "\n";
Output:
2 hours 2 minutes 30 seconds
7350