I want to write a function like to do the following: - I have a date & time like: 23-Aug-2008 23:10 GMT-0400 - I want to display it as : 24-Aug-2008 04:10 GMT+0100 Can you help me to do it? (for PHP4 & PHP5) Thanks.
From PHP 5.1, you can change default timezone either in .INI or with function date_default_timezone_set() to the zone that has GMT +001 (else taken from server time), so you will get the time you need. And earlier versions should support this workaround : date("d-M-Y H:i:s \G\M\T +001",strtotime("+5 hours")), but it's not so dynamic, as soon as you or your hosting change server location/timezone...
Thanks, I know it in PHP 5, but if we set the default time zone, we make all user's time zones be identical. My purpose is each user has each time zone.
What more would you need?? Either you're interested in changing the date format for everybody (no matter where they are), or if you want to accept user's time zones, let them choose when they register or somewhere. You have the same feature here on DP. Then you just fetch the timezone identifier and use it like e.g. putenv("TZ=US/Eastern"); for that user. Is it better??
If a user has chosen its time displayed as: 23 Aug 2008 23:12:00 +0400 If other user has its time displayed as: 23 Aug 2008 23:12:00 +0200 If other user has its time displayed as: 23 Aug 2008 23:12:00 -0400 All time recorded in database in unique DST : 23 Aug 2008 23:12:00 -0400 How the system will display for each user above?