/*
* @param string $local_datetime A datetime string.
* @param string $local_time_zone A timezone identifier, like `UTC`, `Africa/Lagos`,
* etc. The list of valid identifiers is available in
* the List of Supported Timezones at:
* https://www.php.net/manual/en/timezones.php
*/
function local_to_utc_datetime($local_datetime, $local_time_zone)
{
$utc_time_zone = 'UTC';
$format = 'Y-m-d H:i:s';
$dt = new \DateTime($local_datetime, new \DateTimeZone($local_time_zone));
$dt->setTimeZone(new \DateTimeZone($utc_time_zone));
return $dt->format($format);
}