Jump to content

Setting user's timezone?


LanceT

Recommended Posts

you would need to get there time offset to your servers i believe, then +/- accordingly.

 

right I understand I would have to get there time offset but can u give me an example of how it would be if I needed to change the date from the current timezone to central time?

 

Right I'm using

NOW()

 

Is it a simple

 

NOW() - 200

 

Or something like that?

I wouldn't do it via MySQL get the data first in a string than manipulate it with date IE:

 

$offest = -2; //(in hours)
$offest = ($offest * 3600)

if ($offset < 0) 
    date('h:i', (time() - $offest)); 
else
    date('h:i', (time() + $offest)); 

OR if you have teh date in the db

$offest = -2; //(in hours)
$offest = ($offest * 3600)

if ($offset < 0) 
    date('h:i', ($dbTime - $offest)); 
else
    date('h:i', ($dbTime + $offest)); 

 

--FrosT

just create a test script to echo curent server time and base it according to that

 

If I base it off current server time, won't my code have to change if I change servers?

 

So I'm sure there's a way to just get the servers current time and then change it.

 

How?

 

// Edit

 

After looking up some timezone stuff, seems I came across

date_default_timezone_set

 

and

 

date_default_timezone_get

 

Anyone know how to implement these?

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.