@herminia_bruen
In Symfony 4, you can use the DateTime
class to work with UTC timestamps. Here's how you can do it:
1 2 |
$currentTime = new DateTime('now', new DateTimeZone('UTC')); $timestamp = $currentTime->getTimestamp(); |
1 2 3 4 |
$timestamp = 1611949110; // Example timestamp $dateTime = new DateTime('@' . $timestamp); $dateTime->setTimezone(new DateTimeZone('UTC')); $utcDate = $dateTime->format('Y-m-d H:i:s'); |
1 2 |
framework: default_timezone: "UTC" |
By following these steps, you can easily work with UTC timestamps in Symfony 4.