Amit
Amit

Reputation: 569

Python find what is the epoch time after xxxx milliseconds

I am writing a python script which mainly involves decoration of console output.

I have some value called expiration_time which is in milliseconds. When I display expiration_time on console it is hard to find how much time exactly left to expire. User needs to do some calculation to know how much time is left.

So I decided to print epoch time instead. I want to do something like this:

epoch_time_at_which_expiration_will_happen = current_epoch_time + expiration_time_in_milliseconds

I want to output epoch_time_at_which_expiration_will_happen. How can I do it?

Upvotes: 0

Views: 174

Answers (1)

Tony F.
Tony F.

Reputation: 26

Not really sure what you are trying to output, the time at which expiration happens or the time until the expiration?

Either way, I would use a datetime object instead of the epoch time and convert the milliseconds to microseconds. The datetime objects allow you to do the math you want and to display the output formatted nicely.

https://docs.python.org/2/library/datetime.html

Upvotes: 1

Related Questions