Take value from PHP function [the_time('HH:MM')] and change it based on selection in dropdown box with Javascript
Is this possible? I return the time that something was posted v开发者_如何学Cia 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.
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_obj_date.asp
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.
精彩评论