-1

I am new to this forum and learning.

I want to ask that how can I change my time in PHP? As the entries storing on MySQL are in a different timezone.

I have tried everything but no results.

For example:

  1. SET SESSION time_zone = "-4:00";

  2. htaccess #Adjust default time zone
    SetEnv TZ America/Washington

  3. even changing in select php version

I tried most of the options but nothing seems to work. I even tried contacting my hosting provider, he said no as it is shared hosting or he doesn't know how to do it.

Martin Evans
  • 45,791
  • 17
  • 81
  • 97

1 Answers1

0

You can use date_default_timezone_set function as below:

date_default_timezone_set('America/Anchorage');
echo date("Y-m-d H:i:s");

But as far as I know, there is not a legal time zone America/Washington. Please correct this and you can check available timezone on this link https://www.php.net/manual/en/timezones.america.php. Hope it helps you!!

Rohit Mittal
  • 2,064
  • 2
  • 8
  • 18