How to get unix timestamp with local time as GMT?

Hello,

I have time set to local time zone as source.

'2024-03-15 00:32'

How to get this local time as unix timestamp relative to GMT timezone?

And using this $gmt_timestamp I want to get the same time as below code

date_default_timezone_set('Europe/Istanbul');
echo date('Y-m-d H:i', $gmt_timestamp);
Output: 2024-03-15 00:32

If I save it to the database as a local time timestamp, local time + 3 more hours are added because the local time zone is applied when showing the date on more than one page.

I believe if I save the local time as GMT in a unix timestamp to the database it will show the time correctly on other pages

I try something like this, but I get +3 hours forward time.

$timestamp = gmmktime(00, 32, 0, 03, 21, 2024);

$gmt = strtotime('2024-03-21 00:32 GMT');
echo $gmt."<br>".$timestamp;
echo "<br>";
echo date('Y-m-d H:i', $timestamp);

The above code output:
1710981120 // GMT
1710981120 // GMMKTIME
2024-03-21 03:32

By entering Istanbul instead of GMT as below, I got the GMT unix timestamp and showed the local date again

$gmt = strtotime('2024-03-21 00:32 Europe/Istanbul');
echo date_tr('Y-m-d H:i', $gmt);
Output: 2024-03-21 00:32
Sponsor our Newsletter | Privacy Policy | Terms of Service