简体   繁体   中英

Create Unix timestamp given the time only

I have a time value, in seconds, for example 4:20pm being 58800 . From this value I need to get the Unix timestamp, assuming today's date. How should I approach this?

start_of_day = datetime.datetime.combine(datetime.date.today(), datetime.time())
dt = start_of_day + datetime.timedelta(seconds=58800)

Like so?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM