Convert UTC time to Local time

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dave914
Forum Newbie
Posts: 2
Joined: Thu Sep 16, 2004 2:35 pm

Convert UTC time to Local time

Post by dave914 »

How do I take a Zulu/GMT/UTC time like 1643 and convert it to a local time like 8:00PM? Also, how would I convert a Zulu/GMT/UTC time like 1643 to a UNIX timestamp? Do I need to know the month, day, and year before I can convert the UTC time to a local time?? I'm so confused. I'm thinking I may need to use gmmktime, but I'm not really sure. Please include a code snippet. Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

wouldn't that be 4:43PM ?

anyways.. you can use a regular expression to extract the numbers out. Then pass them to gmmktime.

You can look here for information on regular expressions.
dave914
Forum Newbie
Posts: 2
Joined: Thu Sep 16, 2004 2:35 pm

Post by dave914 »

How do I pass the numbers to gmmktime? Can you give me an example? I know how to extract the numbers out using a regex, but how do they get passed to gmmktime? Also, do I have to pass a day, month, and year to gmmktime?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

have you looked at

[php_man]gmmktime[/php_man]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I don't quite see how you wouldn't know how to pass data to a function if you know how to extract the information with a regular expression... and yes, you need to pass the date.
Post Reply