As I am stripping out specific PostgreSQL functions from CoolPBX, one of the things I found is using the field timestamptz. This kind of field saves a timestamp in ISO 8601 format, which stores the date, time stamp and timezone.

Sadly, SQLite and MySQL/MariaDB lack this.  But who needs this if we have Unix time.

From Timestamp to Unix Time

$start_stamp_begin = '2024-02-14 12:00';
$timezone = 'America/Toronto';
$start_epoch_begin = strtotime($start_stamp_begin.' '.$time_zone); // 1707923880

From Unix Time to Timestamp

$dt = new DateTime('@1707923880');
$dt->setTimeZone(new DateTimeZone('America/Chicago'));
echo $dt->format('F j, Y, g:i a'); //February 14, 2024, 9:18 am

Good luck!

";