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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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