Jump to content
xisto Community
Sign in to follow this  
flashy

Php Date()? timezone is offset

Recommended Posts

Hi my timezone is GMT and the code im using to display the time and date is this:

date('l j F - g:i a')

which would then display "Tuesday 25 March - 12:11 am"

But the time for me at the time was 07:11 am. Anyone know how to tune it so it is with GMT time?
Edited by flashy (see edit history)

Share this post


Link to post
Share on other sites

Can you list some code and/or maybe the steps you are taking to handle the date? When you say it just doesn't work we have no idea what just doesn't work. The kettle doesn't work? My lines on the girls don't work? Please be a bit more specific about your problem if you wish to get better help. In your case I'm assuming your piece of code isn't doing what you want it to do so please post it so we can take a look.

Share this post


Link to post
Share on other sites

OK i found out how to do it! I did a bit of google and this worked completely for me and it is simple.

I used this code

putenv("TZ=UK");echo("h:i:s");

If you like in the United States and you live say Los Angeles you would do this...
putenv("TZ=US/Los_Angeles");echo("h:i:s");

The full TimeZones are here

You can set the default timezone like this:
date_default_timezone_set('UTC');

And you can then format it
<?php// Assuming today is: March 10th, 2001, 5:16:18 pm$today = date("F j, Y, g:i a");				 // March 10, 2001, 5:16 pm$today = date("m.d.y");						 // 03.10.01$today = date("j, n, Y");					   // 10, 3, 2001$today = date("Ymd");						   // 20010310$today = date('h-i-s, j-m-y, it is w Day z ');  // 05-16-17, 10-03-01, 1631 1618 6 Fripm01$today = date('\i\t \i\s \t\h\e jS \d\a\y.');   // It is the 10th day.$today = date("D M j G:i:s T Y");			   // Sat Mar 10 15:16:08 MST 2001$today = date('H:m:s \m \i\s\ \m\o\n\t\h');	 // 17:03:17 m is month$today = date("H:i:s");						 // 17:16:17?>
Notice from jlhaslip:
Merged

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.