Jump to content

Help me convert/format UTC offset to hours "-270" = "-04:30"


theJay

Recommended Posts

Hopefully somebody can help me with this little bit of code, it's been awhile since I wrote php so I’m rusty and things have changed; I am coding this for PHP 5.2x to take advantage of the new date/time/dst functions.

 

Right now I have UTC timezone offsets in minutes "-660" through "840" stored in a database, and I want to display them as "-11:00" through "+14:00"; with leading zeros on single digit hours “-270” would show "-04:30".

 

I want to do this with the least amount of code possible, using optimal functions; it took me too many lines of code and I know it can be done much better with less code.

 

Also, is there an existing database or function with the PHP timezones (http://us3.php.net/manual/en/timezones.php) to get the actual countries they belong to (php groups them in a very user unfriendly geographic way); there is almost 500 and I would hate to do the country codes manually; if you know any tricks to do this let me know and save me some major time.

 

To see what I am attempting to do with country/timezones drop-down list, login to google and go here: https://www.google.com/accounts/EditUserInfo (select country, uncheck display all countries).

 

Thanks for the help, hopefully down the road when I shake off the rust I can return the favor.

 

Archived

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

×
×
  • 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.