Convert peaceful time sequence to time

I have time strings like PT19H15M, PT10H, PT5M, etc.

PT19H15M is 19:15; PT10H is 10:00; PT5M is 00:05

I want to convert each line to normal time.

is there a built-in method

+4
source share
1 answer

Formatted as the duration of ISO 8601 , which is supported DateInterval, which has a convenient method format.

So for example:

echo (new DateInterval("PT19H15M"))->format("%H:%I");

will output:

19:15

, "PT" Pacific Time. P , T - , .., , . P2YT19H 2 19 .

+6

Source: https://habr.com/ru/post/1682284/


All Articles