from datetime import datetime
from pytz import timezone
format = '%Y-%m-%d %I:%M:%S %p %Z%z'
# UTC time
now_utc = datetime.now(timezone('UTC'))
print(now_utc.strftime(format))
# 2021-04-13 06:14:05 AM UTC+0000
# WIB time
now_jkt = now_utc.astimezone(timezone('Asia/Jakarta'))
print(now_jkt.strftime(format))
# 2021-04-13 13:14:05 PM WIB+0700
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.