onenonly Posted June 20, 2009 Share Posted June 20, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/163026-solved-php-date-function-wrong-time/ Share on other sites More sharing options...
Daniel0 Posted June 20, 2009 Share Posted June 20, 2009 Because your server's clock is running behind or because your server is in another time zone than you are. Quote Link to comment https://forums.phpfreaks.com/topic/163026-solved-php-date-function-wrong-time/#findComment-860180 Share on other sites More sharing options...
RussellReal Posted June 20, 2009 Share Posted June 20, 2009 date_default_timezone_set Quote Link to comment https://forums.phpfreaks.com/topic/163026-solved-php-date-function-wrong-time/#findComment-860184 Share on other sites More sharing options...
onenonly Posted June 22, 2009 Author Share Posted June 22, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/163026-solved-php-date-function-wrong-time/#findComment-861487 Share on other sites More sharing options...
ldougherty Posted June 22, 2009 Share Posted June 22, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/163026-solved-php-date-function-wrong-time/#findComment-861489 Share on other sites More sharing options...
onenonly Posted June 22, 2009 Author Share Posted June 22, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/163026-solved-php-date-function-wrong-time/#findComment-861511 Share on other sites More sharing options...
thebadbad Posted June 22, 2009 Share Posted June 22, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/163026-solved-php-date-function-wrong-time/#findComment-861548 Share on other sites More sharing options...
onenonly Posted June 22, 2009 Author Share Posted June 22, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/163026-solved-php-date-function-wrong-time/#findComment-861563 Share on other sites More sharing options...
PFMaBiSmAd Posted June 22, 2009 Share Posted June 22, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/163026-solved-php-date-function-wrong-time/#findComment-861564 Share on other sites More sharing options...
RussellReal Posted June 23, 2009 Share Posted June 23, 2009 shared hosting actually doesn't usually ALLOW php.ini modification Quote Link to comment https://forums.phpfreaks.com/topic/163026-solved-php-date-function-wrong-time/#findComment-861609 Share on other sites More sharing options...
PFMaBiSmAd Posted June 23, 2009 Share Posted June 23, 2009 They do using a local php.ini Quote Link to comment https://forums.phpfreaks.com/topic/163026-solved-php-date-function-wrong-time/#findComment-861645 Share on other sites More sharing options...
RussellReal Posted June 23, 2009 Share Posted June 23, 2009 shared hosting actually doesn't usually ALLOW php.ini modification I tried reading this 3 times fast and its like a brain twister.. lol Quote Link to comment https://forums.phpfreaks.com/topic/163026-solved-php-date-function-wrong-time/#findComment-861678 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.