Разница во времени на 12 секунд из timestamp

Пытаюсь сделать таймер и отобразить оставшееся время на странице.

Время когда таймер стартанул:

$timeZone = new DateTimeZone('Europe/Riga');
$now = new DateTimeImmutable('now', $timeZone);

И сохраняю в базу:

$entity->setTimer($now);

$this->em->persist($entity);
$this->em->flush();

Беру timestamp:

$dateTime = $entity->getTimer();
$dateTime->getTimestamp();

Дальше на FE:

const currentD = new Date();
const startD = new Date(timestamp * 1000);
const timer = 5; // Таймер в минутах
let endD = new Date(timestamp * 1000);

endD.setMinutes(startD.getMinutes() + timer);

const remainingTimeMinutes = Math.floor((endD - currentD) / 60000);
const remainingTimeSeconds = (((endD - currentD) % 60000) / 1000).toFixed(0);

И почему то startD на ~12 секунд больше чем currentD. Из-за чего так происходит?

Fri May 20 2022 10:05:04 GMT+0300 // currentD

Fri May 20 2022 10:05:13 GMT+0300 // startD


Ответы (0 шт):