Reputation: 19375
I have a list of POSIX timestamps such as 1331567982
that I process using datetime.utcfromtimestamp
which gives me a date format like: year - month - day - hour - minute - seconds
.
However, for resampling purposes I just need to extract the timestamp up to the minute precision, that is year - month - day - hour - minute
, but no seconds.
How can I do that using functions from the datetime
module only (no Pandas)?
Upvotes: 0
Views: 1291
Reputation: 410672
You can use the datetime.replace
function:
import datetime
d = datetime.datetime.utcfromtimestamp(1331567982)
d.replace(second=0, microsecond=0)
Upvotes: 3