Question

I have a total time output:

Fig. A

01:02:00

I want it to be displayed like this:

Fig. B

00:01:02

I want the hour and minute on the Fig. A, should move on the minute and seconds on the Fig. B

I also want to divide the Fig. B to an integer and get the quotient.

Fig. C

$b = 00:01:02;
$quotient = $b / $integer;

echo $quotient;

ex:

00:01:00 / 4 = 00:00:15
Was it helpful?

Solution

Use Datetime::createFromFormat for the first part.

$date = DateTime::createFromFormat('H:i:s', '01:02:00');

echo $date->format("s:H:i");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top