0

I have a timezone aware datetime date object:

Timestamp('2004-03-29 00:00:00-0456', tz='America/New_York') 

and a number of mili seconds since midnight (midnight in the local timezone):

34188542

How to combine them to get a valid datetime?

2 Answers 2

4

Create a timedelta object and add it to you time like this:

td = datetime.timedelta(milliseconds=34188542) date_object = datetime.datetime.now() + td # change to your datetime object, I just use `now()` 
Sign up to request clarification or add additional context in comments.

Comments

1

Assuming the datetime object is ts, and by "combine them", you mean "add them":

ms = 34188545 new_datetime = ts + datetime.timedelta(milliseconds = ms) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.