0

The range of my timestamp is from 34200 to 57600, so it covers a part of one day from 9:30 AM). I want to add a specific year/month/day to this timestamp. How can I do that in python? Suppose that my timestamp is 34201.054427731004. I want a timestamp with information about year/month/day (for example, 3/2/2017) as the output. So here, the UNIX output is a full timestamp not just the hour/mean/sec.

8
  • 1
    Unclear how either 34200 or 57600 "cover a 24h day", or what the expected result is. Commented Feb 25, 2019 at 13:51
  • 1
    It does not cover 24h : 34200 is 9hours and 30 minutes and 57600 is 16 hours Commented Feb 25, 2019 at 13:52
  • @deceze I edited the question. Commented Feb 25, 2019 at 13:55
  • Yeah, still not much better. Instead of describing what you think you have or want, show us what concrete values you expect to get here. Commented Feb 25, 2019 at 13:55
  • Yeah, not seeing how 34201.054427731004 relates to "3/2/2017" at all. Commented Feb 25, 2019 at 13:56

1 Answer 1

2

Make a datetime object with the date, which will initialise hours and minutes to 0, and add a timedelta with the seconds to it:

from datetime import datetime, timedelta

date = datetime(2017, 2, 3) + timedelta(seconds=34201)
print(date.timestamp())
Sign up to request clarification or add additional context in comments.

2 Comments

Is this consider .054427731004 part of timestamp?
If you add them (seconds=123.456), yes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.