hey guys im using these 2 functions
def utc_to_local(utc_dt):
return utc_dt.replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz('America/New_York'))
def perdelta(start, end, delta):
curr = start
while curr < end:
yield curr
curr += delta
for result in perdelta(utc_to_local(datetime.datetime.utcnow()- datetime.timedelta(minutes= 120)),utc_to_local(datetime.datetime.utcnow()- datetime.timedelta(minutes=60)), datetime.timedelta(minutes=1)):
print(result)
the result of this code gives me a list of timestamps of what I want
2021-02-02 19:00:03.438953-05:00
2021-02-02 19:01:03.438953-05:00
2021-02-02 19:02:03.438953-05:00
2021-02-02 19:03:03.438953-05:00
2021-02-02 19:04:03.438953-05:00
2021-02-02 19:05:03.438953-05:00
2021-02-02 19:06:03.438953-05:00
2021-02-02 19:07:03.438953-05:00
2021-02-02 19:08:03.438953-05:00
2021-02-02 19:09:03.438953-05:00
2021-02-02 19:10:03.438953-05:00
2021-02-02 19:11:03.438953-05:00
2021-02-02 19:12:03.438953-05:00
2021-02-02 19:13:03.438953-05:00
2021-02-02 19:14:03.438953-05:00
2021-02-02 19:15:03.438953-05:00
2021-02-02 19:16:03.438953-05:00
2021-02-02 19:17:03.438953-05:00
2021-02-02 19:18:03.438953-05:00
2021-02-02 19:19:03.438953-05:00
2021-02-02 19:20:03.438953-05:00
2021-02-02 19:21:03.438953-05:00
2021-02-02 19:22:03.438953-05:00
2021-02-02 19:23:03.438953-05:00
2021-02-02 19:24:03.438953-05:00
2021-02-02 19:25:03.438953-05:00
2021-02-02 19:26:03.438953-05:00
2021-02-02 19:27:03.438953-05:00
2021-02-02 19:28:03.438953-05:00
2021-02-02 19:29:03.438953-05:00
2021-02-02 19:30:03.438953-05:00
2021-02-02 19:31:03.438953-05:00
2021-02-02 19:32:03.438953-05:00
2021-02-02 19:33:03.438953-05:00
2021-02-02 19:34:03.438953-05:00
2021-02-02 19:35:03.438953-05:00
2021-02-02 19:36:03.438953-05:00
2021-02-02 19:37:03.438953-05:00
2021-02-02 19:38:03.438953-05:00
2021-02-02 19:39:03.438953-05:00
2021-02-02 19:40:03.438953-05:00
2021-02-02 19:41:03.438953-05:00
2021-02-02 19:42:03.438953-05:00
2021-02-02 19:43:03.438953-05:00
2021-02-02 19:44:03.438953-05:00
2021-02-02 19:45:03.438953-05:00
2021-02-02 19:46:03.438953-05:00
2021-02-02 19:47:03.438953-05:00
2021-02-02 19:48:03.438953-05:00
2021-02-02 19:49:03.438953-05:00
2021-02-02 19:50:03.438953-05:00
2021-02-02 19:51:03.438953-05:00
2021-02-02 19:52:03.438953-05:00
2021-02-02 19:53:03.438953-05:00
2021-02-02 19:54:03.438953-05:00
2021-02-02 19:55:03.438953-05:00
2021-02-02 19:56:03.438953-05:00
2021-02-02 19:57:03.438953-05:00
2021-02-02 19:58:03.438953-05:00
2021-02-02 19:59:03.438953-05:00
2021-02-02 20:00:03.438953-05:00
But what I want to achieve to have each timestamp round to the nearest minute. For example I want 19:00:03.438953
, 19:01:03.438953
, 19:02:03.438953
, 19:03:03.438953
to be converted to 19:00:00
, 19:01:00
, 19:02:00
, ..., ... etc to the final timestamp. I haven't yet been able to figure out to implement this. Any ideas ?