kippo
kippo copied to clipboard
def nowUnix returns the wrong time
In core/dblog.py, line 61: def nowUnix(self): """return the current UTC time as an UNIX timestamp""" return int(time.mktime(time.gmtime()[:-1] + (-1,)))
If I just run this inside python:
import time int(time.mktime(time.gmtime()[:-1] + (-1,))) 1433447440
If i just run this from command line: $ date +"%s" $ 1433483440
It's 36000 seconds off, is this normal?
Sounds very much as a timezone gone wrong. My guess is that the python code returns the timestamp in GMT and your system is set to GMT+1 or GMT-1.
Could this be the case?
On June 5, 2015 8:22:55 AM GMT+02:00, nojeffrey [email protected] wrote:
In core/dblog.py, line 61: def nowUnix(self): """return the current UTC time as an UNIX timestamp""" return int(time.mktime(time.gmtime()[:-1] + (-1,)))
If I just run this inside python:
import time int(time.mktime(time.gmtime()[:-1] + (-1,))) 1433447440
If i just run this from command line: $ date +"%s" $ 1433483440
It's 36000 seconds off, is this normal?
Reply to this email directly or view it on GitHub: https://github.com/desaster/kippo/issues/188
I'm in +10 timezone here which is 36000 seconds off UTC time. But the timestamp in the DB is not UTC or my +10 either My system timezone is set to +10, so my current time is 17:27
if I run: >>> time.time(), in python it returns the right epoch time(UTC): 1433489239 If i run: date +"%s" it return the same epoch time as above(1433489239). If I run: date --utc, it returns: Fri Jun 5 07:27:35 UTC 2015
If i do a failed SSH login, and check the DB, I see this line: +----+----------------------------------+---------+----------+------------+---------------------+ | id | session | success | username | password | timestamp | +----+----------------------------------+---------+----------+------------+---------------------+ | 1 | c951bdba0b5211e5b632005056ba4905 | 0 | root | xzlgnfkakj | 2015-06-05 08:27:30 | +----+----------------------------------+---------+----------+------------+---------------------+
This timestamp is 1 hour off of UTC time, and 11 hours off my +10 timezone. Is something in: "return int(time.mktime(time.gmtime()[:-1] + (-1,)))" modifying the time by 1 hour?