webguync Posted January 27, 2010 Share Posted January 27, 2010 Hi, I am printing out a date as such echo date('l jS \of F Y h:i:s A'); The server is on west coast and I am on east coast. It displays west coast time and I want to adjust -3 hours for east coast time. I have seen it done before but cannot find reference to how it is done right off hand. The server has PHP 4 installed if that makes a difference. I also want to display the time one hour ahead such as echo "one hour from now will be (php)"; Quote Link to comment https://forums.phpfreaks.com/topic/190039-altering-time-per-timezone-and-displaying-time-one-hour-from-current-time/ Share on other sites More sharing options...
taquitosensei Posted January 27, 2010 Share Posted January 27, 2010 date_default_timezone_set('America/New_York'); Quote Link to comment https://forums.phpfreaks.com/topic/190039-altering-time-per-timezone-and-displaying-time-one-hour-from-current-time/#findComment-1002630 Share on other sites More sharing options...
webguync Posted January 27, 2010 Author Share Posted January 27, 2010 I must be writing it wrong, gives me an error <? date_default_timezone_set('America/New_York'); echo date('l jS \of F Y h:i:s A'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/190039-altering-time-per-timezone-and-displaying-time-one-hour-from-current-time/#findComment-1002658 Share on other sites More sharing options...
PFMaBiSmAd Posted January 27, 2010 Share Posted January 27, 2010 gives me an error Yes, but what was the error, as that would allow someone to help determine how to fix it. Quote Link to comment https://forums.phpfreaks.com/topic/190039-altering-time-per-timezone-and-displaying-time-one-hour-from-current-time/#findComment-1002666 Share on other sites More sharing options...
webguync Posted January 28, 2010 Author Share Posted January 28, 2010 yes, I suppose that would help, sorry. Fatal error: Call to undefined function: date_default_timezone_set() in path/to/file on line 173 Quote Link to comment https://forums.phpfreaks.com/topic/190039-altering-time-per-timezone-and-displaying-time-one-hour-from-current-time/#findComment-1003082 Share on other sites More sharing options...
ChemicalBliss Posted January 28, 2010 Share Posted January 28, 2010 Forget that lol use this easy fix: echo date('l jS \of F Y h:i:s A',time()-10800); // 10800 = 3 hours in seconds. -CB- Quote Link to comment https://forums.phpfreaks.com/topic/190039-altering-time-per-timezone-and-displaying-time-one-hour-from-current-time/#findComment-1003086 Share on other sites More sharing options...
PFMaBiSmAd Posted January 28, 2010 Share Posted January 28, 2010 The server has PHP 4 installed if that makes a difference You need to plan your upgrade to php5. The end of life of php4 was slightly over 2 years ago. Quote Link to comment https://forums.phpfreaks.com/topic/190039-altering-time-per-timezone-and-displaying-time-one-hour-from-current-time/#findComment-1003088 Share on other sites More sharing options...
webguync Posted January 29, 2010 Author Share Posted January 29, 2010 ha, it's a hosting company, so I guess I need to pester them. I got this to work, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/190039-altering-time-per-timezone-and-displaying-time-one-hour-from-current-time/#findComment-1003771 Share on other sites More sharing options...
PFMaBiSmAd Posted January 29, 2010 Share Posted January 29, 2010 Most web hosts have provide a way of switching to php5, either through a control panel setting or through a setting in a .htaccess file. Quote Link to comment https://forums.phpfreaks.com/topic/190039-altering-time-per-timezone-and-displaying-time-one-hour-from-current-time/#findComment-1003774 Share on other sites More sharing options...
webguync Posted January 29, 2010 Author Share Posted January 29, 2010 ok, thanks. I will get in touch with their technical support about upgrading. Quote Link to comment https://forums.phpfreaks.com/topic/190039-altering-time-per-timezone-and-displaying-time-one-hour-from-current-time/#findComment-1003781 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.