Created
May 18, 2021 15:29
-
-
Save bruno-uy/fd447fdf0e749117f7e266d8c894c2aa to your computer and use it in GitHub Desktop.
Round up UTC now timestamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
utc_now_pd = pd.Timestamp.utcnow() | |
# The function round(freq="D") is magic behind the round up | |
# Use replace(tzinfo=None) to remove timezone information | |
utc_now_ceil = utc_now_pd.round(freq="D").to_pydatetime().replace(tzinfo=None) | |
# Convert to ISO format | |
utc_now_str = utc_now_ceil.strftime("%Y-%m-%dT%H:%M:%S") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to subtract some days just do: