Javascript timezone solution needed(taking into account the actual difference in UTC timestamps)

Posted by user198729 on Stack Overflow See other posts from Stack Overflow or by user198729
Published on 2010-05-29T14:27:30Z Indexed on 2010/05/29 15:32 UTC
Read the original article Hit count: 257

Filed under:
|
|

I have unix timestamps from time zone X which is not known,

the current timestamp(now()) in TZ X is known 1275143019,

how to approach a javascript function so that it can generate the datetime in the users current TZ in the format 2010-05-29 15:32:35 ?

UPDATE

I'm not a unix timestamp expert,if unix timestamp is always the same in different TZ,

then I have to change the question a little,so that the current datetime in TZ X is known(like 2010-05-29 22:32:28),and the other datetime is also in this format,how to convert them to the user's TZ based on the difference between now() ?

UPDATE

Something strange from MySQL:

On server:

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2010-05-29 18:34:30 | 
+---------------------+
1 row in set (0.00 sec)

mysql> select UNIX_TIMESTAMP();
+------------------+
| UNIX_TIMESTAMP() |
+------------------+
|       1275143674 | 
+------------------+
1 row in set (0.00 sec)

On local:

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2010-05-29 22:41:30 |
+---------------------+
1 row in set (0.00 sec)

mysql> select UNIX_TIMESTAMP();
+------------------+
| UNIX_TIMESTAMP() |
+------------------+
|       1275144091 |
+------------------+
1 row in set (0.00 sec)

Why the difference between now() (2010-05-29 22:41:30-2010-05-29 18:34:30=6hours) and UNIX_TIMESTAMP() (1275144091 - 1275143674 = 417seconds) is not the same ?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about mysql