views:

63

answers:

2

Is this possible? I return the time that something was posted via PHP function from the database and adjust it based on timezone data selected in a drop down box with Javascript on the client side.

For example: The PHP would return 5:00 PM GMT as the time, and if they selected EST it would subtract 5 hours from the time automagically.

Addendum: I just need to be able to, using a value in a drop box, deduct a numeric value from the returned time variable and display it in the users browser.

A: 

It's possible, but every time the page refreshes the time zone information will be lost. You should probably use the server-side $_SESSION to store the timezone, and when it's displayed to the user account for the difference in PHP.

John Rasch
The problem is that we do not have a user account nor $_SESSION to utilize. Instead, I have a script to detect and populate the default value of the dropdown box with the users timezone.
Jeff
Can you not also pull the time along with the timezone if you already have a script that gets the timezone?
John Rasch
Yeah, I could pull the users local time, but I need to change the time articles were posted based on the individual users timezone.
Jeff
A: 

Use the Javascript Date function? Pass the date to JS and then change it based on your dropdown select.

http://www.w3schools.com/jS/js%5Fobj%5Fdate.asp

Peeter