-1

I generate a current timestamp like this:

<?php echo time(); ?>

The result is:

1589352983

Now I woule like to get all data from my mysql database where my row "time" is > than my current timestamp value.

The problem is, that my timestamp value has not the correct time zone. How can I set the time zone for my timestamp ?

I need GMT+02:00

UPDATE

I insert data into my mysql database. At this moment a timestamp will automatically create by mysql and will stored in the row "time"

In my php script I start a query where my php timestamp (which can be in the past, because it was generated minutes before) is < timestamp of my database

SELECT * FROMtableWHEREtime> 1589354666 ORDER BYtimeDESC

1589354666 = the timestamp from my php script.

But here I get all my data because the timestamp is converted: 13.05.2020 09:24:26

But it will compare with the value: 13.05.2020 07:24:26

Trombone0904
  • 4,132
  • 8
  • 51
  • 104

1 Answers1

0

You can set the timezone in php before you run time(); This way php will return time for that timezone

<?php
date_default_timezone_set("Asia/Bangkok");
echo date_default_timezone_get();
?>

You can find a list of all supported timezones here

Ebenezer Isaac
  • 772
  • 1
  • 8
  • 31