D.Rattansingh Posted October 25, 2011 Share Posted October 25, 2011 When I echo the current time, the hour is what it is plus one: echo date("h:i:s:A"); Real time is 3:46:33 Would display 4:46:33 What is wrong here? Link to comment https://forums.phpfreaks.com/topic/249796-current-time-isnt-displaying-the-correct-hour/ Share on other sites More sharing options...
xtopolis Posted October 25, 2011 Share Posted October 25, 2011 The server may be in a different timezone than yourself. Link to comment https://forums.phpfreaks.com/topic/249796-current-time-isnt-displaying-the-correct-hour/#findComment-1282202 Share on other sites More sharing options...
jcbones Posted October 25, 2011 Share Posted October 25, 2011 If you have PHP5 you should get prompted to set the date_default_timezone_set in any script that runs a date function. Of course, this is if you have error_reporting and display_errors turned on in your development enviroment. Link to comment https://forums.phpfreaks.com/topic/249796-current-time-isnt-displaying-the-correct-hour/#findComment-1282215 Share on other sites More sharing options...
D.Rattansingh Posted October 26, 2011 Author Share Posted October 26, 2011 I am using PHP5.2 and I'm using localhost. I have display_error() set to On and error_reporting() set to E_ALL. Still isn't getting anything. Link to comment https://forums.phpfreaks.com/topic/249796-current-time-isnt-displaying-the-correct-hour/#findComment-1282269 Share on other sites More sharing options...
xtopolis Posted October 26, 2011 Share Posted October 26, 2011 Check the server itself, run a current time command. Narrow down the problem. It's either incorrect server time, or a daylight savings setting or something I'm guessing. Link to comment https://forums.phpfreaks.com/topic/249796-current-time-isnt-displaying-the-correct-hour/#findComment-1282271 Share on other sites More sharing options...
jcbones Posted October 26, 2011 Share Posted October 26, 2011 To repeat, your timezone setting is off, you can fix it by date_default_timezone_set. functions: Runtime date_default_timezone_set EX. date_default_timezone_set('America/New_York'); ini_set EX ini_set('date.timezone','America/New_York'); OR, it can be set in the php.ini. Link to comment https://forums.phpfreaks.com/topic/249796-current-time-isnt-displaying-the-correct-hour/#findComment-1282274 Share on other sites More sharing options...
D.Rattansingh Posted November 10, 2011 Author Share Posted November 10, 2011 Hey thanks. I modified in the .ini file: ;date.timezone = "US/Central" Regards. Link to comment https://forums.phpfreaks.com/topic/249796-current-time-isnt-displaying-the-correct-hour/#findComment-1286896 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.