max
max

Reputation: 2396

MySQL from_unixtime() and Python time.ctime() not agreeing

I have some data that uses unixtime. I'm using Python and MySQL.

I have noticed that the MySQL GUI Tools function from_unixtime() doesn't equal Python's output of time.ctime() or even the MySQL cmd line interface...

MySQL Command Line:

#This returns the correct time

mysql> select from_unixtime(1295147016.45300);
+---------------------------------+
| from_unixtime(1295147016.45300) |
+---------------------------------+
| 2011-01-15 21:03:36             |
+---------------------------------+
1 row in set (0.05 sec)

MySQL GUI Tools:

# Incorrect Time!

select from_unixtime(1295147016.45300);

2011-01-16 03:03:36 

Python:

#This returns the correct time

>>> import time
>>> time.ctime(1295147016.45300)
'Sat Jan 15 21:03:36 2011'

Can someone please shed some light on the discrepancies? What's the point of having a GUI if it doesn't show the correct data.

Thanks,
M

Upvotes: 1

Views: 1330

Answers (1)

shamittomar
shamittomar

Reputation: 46702

The time zone is different in both the cases. Just fix the time-zone in MySQL GUI tools and you're good to go.

Upvotes: 1

Related Questions