[Solved] Local PHP Date/Time is not working properly

I had a little problem running date(“F j, Y, g:i a”); function, it works fine at the first time but then I notice that it displays different time from my computer.

	echo date("F j, Y, g:i a");


June 10, 2011, 9:35 am 

The correct output is June 10, 2011 5:30 pm but instead it’s 7 hours way behind.
Time and date is important in my program because I want to record when and what date-time user log-ins.

There are lots of ways on how to solve this kind of problem, but I’m going to show only 2 solutions by modifying .htaccess or php.ini. Since, I’m from Philippines I’ll be using “Asia/Manila” timezone.

1. Using .htacess:

php_value date.timezone "Asia/Manila"

2. Modifying php.ini

date.timezone = "Asia/Manila"

My timezone references are:

This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to [Solved] Local PHP Date/Time is not working properly

  1. It is really helpful when time and date is not work.

  2. koushik chhetri says:

    Please do not change the php.ini because this is system stuff for php engine.
    Use date_default_timezone_set(“Give your timezone name”)

    • Paolo says:

      Yes, you’re absolutely correct! Koushik. It’s not advisable to change the php.ini, especially if you don’t have enough knowledge about what’s inside php.ini file.

      Koushik is right you can use:

      date_default_timezone_set(“Give your timezone name”);

      If problem still persist you better call your hosting support.

Comments are closed.