-
-
Save shanehh/04a26a9f9aaaefa581ae62af37b374ff to your computer and use it in GitHub Desktop.
python now time str in utc8
This file contains hidden or 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
def utc8_now(): | |
import datetime | |
dt = datetime.datetime.now() + + datetime.timedelta(hours=+8) | |
ts = dt.timestamp() | |
return datetime.datetime.utcfromtimestamp( | |
ts).strftime("%Y-%m-%d-%H:%M:%S") + "-UTC+8:00" | |
# 2021-03-02-14:45:57-UTC+8:00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment