Question

I'm using date_default_timezone_set function to set the timezone but when I echo the time it displays wrong time on local server xampp

date_default_timezone_set ('Africa/Cairo');
echo "<div style='direction:ltr'>".date("Y-m-d / g:i A")."</div>";

the time now is 10:50 am but it displays 9:50 am. So any ideas?

Was it helpful?

Solution

Possible issues:

  • the server's time is not set correctly, test this by confirming that time in the UTC timezone is correct
  • the timezonedb is outdated and the timezone in question has changed its DST rules in the meantime, update your PHP version and/or your timezonedb via PECL
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top