P
P
pavlikmd2018-02-12 00:09:38
PHP
pavlikmd, 2018-02-12 00:09:38

How to add time to time?

Hello, I'll be brief, there are 2 variables:
1) $time1 = "00:08:27";
2) $time2 = "00:01:32";
how to get as a result: 00:09:59 ?
tried it with strtotime

$d1 = strtotime("00:08:27");
$d2 = strtotime("00:01:32");
echo gmdate("H:i:s", $d1 + $d2);

outputs 22:09:59 where it takes 22 hours i xs. In general, how to make it so that there is a normal result?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lumore, 2018-02-12
@pavlikmd

https://ru.stackoverflow.com/questions/437355/%D0%...

S
Stalker_RED, 2018-02-12
@Stalker_RED

If something doesn't work for you, try reading the instructions.

gmdate — Formats a GMT date/time
Description
string gmdate ( string $format [, int $timestamp = time() ] )
This function is identical to the date() function, except that it returns Greenwich Mean Time (GMT).

php.net/manual/ru/function.gmdate.php
You seem to have a time zone of +2, and when you have 00:09:59, it's 22:09:59 in Greenwich.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question