Skip to content

Instantly share code, notes, and snippets.

@shanehh
Created March 2, 2021 06:47
Show Gist options
  • Save shanehh/04a26a9f9aaaefa581ae62af37b374ff to your computer and use it in GitHub Desktop.
Save shanehh/04a26a9f9aaaefa581ae62af37b374ff to your computer and use it in GitHub Desktop.
python now time str in utc8
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