skip to Main Content

Time between two dates in PHP

<?php $timezone='Asia/Tokyo'; $date_time_now = new DateTime('now', new DateTimeZone($timezone)); $date_time_now_formatted = $date_time_now->format('Y-m-d H:i:s'); echo $date_time_now_formatted . '<br>'; $UTC = new DateTime('now', new DateTimeZone('UTC')); $UTC_formatted = $UTC->format('Y-m-d H:i:s'); echo $UTC_formatted . '<br>'; $difference_seconds = $date_time_now->getTimestamp() - $UTC->getTimestamp(); echo $difference_seconds . ' <br>';…

VIEW QUESTION

compare two dateTime Objects in PHP (Symfony 7)

#[Route('/show/{id}', name: 'app_warning_show', methods: ['GET'])] public function show(Warning $warning): Response { $time = new DateTime('now'); $this->checkAccess(['ROLE_WHITELIST','ROLE_FRACTION','ROLE_SUPPORT','ROLE_ADMIN']); return $this->render('warning/show.html.twig', [ 'warning' => $warning, 'expired' => $time > $warning->getEnd(), ]); } Created Datetime in DB -> 2024-04-06 12:13:00 Duration are 10h public…

VIEW QUESTION
Back To Top
Search