Jump to content

Archived

This topic is now archived and is closed to further replies.

onenonly

[SOLVED] Php date function wrong time

Recommended Posts

When i use date() why is it giving me wrong time?

It is an hour ahead of what it suppose to be

 

How can i fix this and why is it like that???

 

Btw i search why and some say u must config with your server provider

Share this post


Link to post
Share on other sites

Because your server's clock is running behind or because your server is in another time zone than you are.

Share this post


Link to post
Share on other sites

so i either use date_default_timezone_set()

to set a certain time in my script right?

 

also is it possible to permanently set it to my timezone?

Share this post


Link to post
Share on other sites

Instead of using this function to set the default timezone in your script, you can also use the INI setting date.timezone to set the default timezone.

 

http://kb.siteground.com/article/How_to_change_the_datetimezone_value_in_PHP.html

 

If your PHP scripts do not show the correct time, the reason is that most probably your hosting server is in a different timezone. This can be easily resolved by changing a setting in PHP called date.timezone.

 

 

 

Depending on your location you can set a specific date.timezone value in PHP using the following option which should be added to your local php.ini file:

 

 

 

date.timezone = "US/Central"

 

 

 

The above example assumes you'd like to set the timezone for your PHP scripts to US/Central. The full list of supported time zones is available here and you should simply replace "US/Central" with the desired timezone.

Share this post


Link to post
Share on other sites

Instead of using this function to set the default timezone in your script, you can also use the INI setting date.timezone to set the default timezone.

 

http://kb.siteground.com/article/How_to_change_the_datetimezone_value_in_PHP.html

 

If your PHP scripts do not show the correct time, the reason is that most probably your hosting server is in a different timezone. This can be easily resolved by changing a setting in PHP called date.timezone.

 

 

 

Depending on your location you can set a specific date.timezone value in PHP using the following option which should be added to your local php.ini file:

 

 

 

date.timezone = "US/Central"

 

 

 

The above example assumes you'd like to set the timezone for your PHP scripts to US/Central. The full list of supported time zones is available here and you should simply replace "US/Central" with the desired timezone.

 

 

 

do you do that once and its permanent? or you must put it on top of all your script?

Share this post


Link to post
Share on other sites

If it goes in your php.ini file it's permanent; if you set it with a function it only applies to the script it's set in.

Share this post


Link to post
Share on other sites

If it goes in your php.ini file it's permanent; if you set it with a function it only applies to the script it's set in.

 

how do I change it permanently

Im on a shared webhost

Share this post


Link to post
Share on other sites

If php is running as an Apache Module, you can put php settings into a .htaccess file. If php is running as a CGI application, you can put php settings into a local php.ini. Check with your web host which method is supported.

Share this post


Link to post
Share on other sites

shared hosting actually doesn't usually ALLOW php.ini modification :o

Share this post


Link to post
Share on other sites

shared hosting actually doesn't usually ALLOW php.ini modification :o

 

I tried reading this 3 times fast and its like a brain twister.. lol

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.