开发者

Converting to timezone with $formatDate = $.PHPDate("U", date);

开发者 https://www.devze.com 2023-02-02 12:34 出处:网络
I am u开发者_运维技巧sing a jquery calendar called fullcalendar. When a user clicks a day they are sent to another page to create an event for that day. The date that was clicked is supplied as date.

I am u开发者_运维技巧sing a jquery calendar called fullcalendar. When a user clicks a day they are sent to another page to create an event for that day. The date that was clicked is supplied as date. It is then run through the function below to convert it to UNIX time.

$formatDate = $.PHPDate("U", date);

I am using the javascript date library found here http://joncom.be/code/jquery-phpdate/

When I alert the date variable I get an output like this

Tue Jan 04 2011 00:00:00 GMT+1100 (EST)

This time is correct BUT after applying the $formatDate function the unix output is not in the correct time zone.

Unfortunately it's returning local times relative to the server and I need it to supply times correct to the users timezone. I note that in the documentation there seems to be timezone references but in the documentation it says that timezones are "UNSUPPORTED"

Please... How can i convert my unix timestamp to the right timezone?

I should point out I have very little experience in javascript and come from a PHP/codeigniter background.

Thanks for your help.

Tim


Here is a nice article explaining a lot about time zones in JavaScript: http://www.hunlock.com/blogs/Javascript_Dates-The_Complete_Reference.

Bottom line is, the output will always be in the user's computer's (or at least, the browser's) timezone. You can test this (I think) by changing the timezone in your computer's settings. You will see the date changing in your browser as well (after a refresh, of course).

Is this what you meant?

0

精彩评论

暂无评论...
验证码 换一张
取 消