Linked Questions

28 votes
2 answers
142k views

What is a classy way to store date and time information in a float in python with millisecond precision? Edit: I'm using python 2.7 I've hacked together the following: DT = datetime.datetime(2016,01,...
Swier's user avatar
  • 4,246
0 votes
0 answers
101 views

example = datetime.datetime(2014, 8, 19, 14, 18, 49, 435413, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=-240, name=None)) datetime.datetime.fromtimestamp(time.mktime(example.timetuple())) datetime....
skyler's user avatar
  • 8,407
834 votes
19 answers
1.4m views

How do I get the current time in milliseconds in Python?
Naftuli Kay's user avatar
  • 92.6k
443 votes
26 answers
874k views

How do I convert a datetime string in local time to a string in UTC time? I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future. ...
Tom's user avatar
  • 44.9k
692 votes
10 answers
1.3m views

Does time.time() in the Python time module return the system's time or the time in UTC?
Saransh Mohapatra's user avatar
496 votes
13 answers
617k views

I have a Python datetime object that I want to convert to unix time, or seconds/milliseconds since the 1970 epoch. How do I do this?
SuperString's user avatar
  • 22.6k
347 votes
17 answers
867k views

How to convert a string in the format "%d/%m/%Y" to timestamp? "01/12/2011" -> 1322697600
Shankar Cabus's user avatar
370 votes
10 answers
608k views

Python provides different packages (datetime, time, calendar) as can be seen here in order to deal with time. I made a big mistake by using the following to get current GMT time time.mktime(datetime....
Cory's user avatar
  • 15.7k
350 votes
14 answers
533k views

I have a python datetime instance that was created using datetime.utcnow() and persisted in database. For display, I would like to convert the datetime instance retrieved from the database to local ...
Nitro Zark's user avatar
  • 3,617
321 votes
13 answers
691k views

I have a bunch of datetime objects and I want to calculate the number of seconds since a fixed time in the past for each one (for example since January 1, 1970). import datetime t = datetime.datetime(...
Nathan Lippi's user avatar
  • 5,277
306 votes
12 answers
280k views

I have to create an "Expires" value 5 minutes in the future, but I have to supply it in UNIX Timestamp format. I have this so far, but it seems like a hack. def expires(): '''return a UNIX style ...
Daniel Rhoden's user avatar
320 votes
12 answers
726k views

I have dt = datetime(2013,9,1,11), and I would like to get a Unix timestamp of this datetime object. When I do (dt - datetime(1970,1,1)).total_seconds() I got the timestamp 1378033200. When ...
kun's user avatar
  • 4,327
315 votes
8 answers
559k views

I have a time in UTC from which I want the number of seconds since epoch. I am using strftime to convert it to the number of seconds. Taking 1st April 2012 as an example. >>>datetime....
Noel's user avatar
  • 4,002
111 votes
11 answers
255k views

Is there a way to get the UTC timestamp by specifying the date? What I would expect: datetime(2008, 1, 1, 0, 0, 0, 0) should result in 1199145600 Creating a naive datetime object means that there ...
pat's user avatar
  • 2,820
77 votes
10 answers
74k views

In Python, how do you find what UTC time offset the computer is set to?
Paul's user avatar
  • 4,480

15 30 50 per page
1
2 3 4 5
8