# How to get unix timestamp with local time as GMT?

**URL:** <https://www.phphelp.com/t/how-to-get-unix-timestamp-with-local-time-as-gmt/36076>\
**Category:** General PHP Help\
**Created:** [March 15, 2024, 12:51pm UTC](https://www.phphelp.com/t/how-to-get-unix-timestamp-with-local-time-as-gmt/36076 "2024-03-15T12:51:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adem](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/a4c791/32.png) [@Adem](https://www.phphelp.com/u/Adem)\
**Post date:** [March 15, 2024, 12:51pm UTC](https://www.phphelp.com/t/how-to-get-unix-timestamp-with-local-time-as-gmt/36076/1 "2024-03-15T12:51:36Z")

</div>

Hello,

I have time set to local time zone as source.

```auto
'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

```auto
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

---

<div class="post-metadata">

**Author:** ![Adem](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/a4c791/32.png) [@Adem](https://www.phphelp.com/u/Adem)\
**Post date:** [March 15, 2024, 7:35pm UTC](https://www.phphelp.com/t/how-to-get-unix-timestamp-with-local-time-as-gmt/36076/2 "2024-03-15T19:35:09Z")

</div>

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

```auto
$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

---

<div class="post-metadata">

**Author:** ![Adem](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/a4c791/32.png) [@Adem](https://www.phphelp.com/u/Adem)\
**Post date:** [March 15, 2024, 10:13pm UTC](https://www.phphelp.com/t/how-to-get-unix-timestamp-with-local-time-as-gmt/36076/3 "2024-03-15T22:13:28Z")

</div>

> [@Adem](#):
>
> `$gmt = strtotime('2024-03-21 00:32 GMT');`

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

```auto
$gmt = strtotime('2024-03-21 00:32 Europe/Istanbul');
echo date_tr('Y-m-d H:i', $gmt);
Output: 2024-03-21 00:32

```
