Using Time.Now API with Python
Python's `datetime` library is powerful but complex when dealing with live server synchronization or geolocation. Use our JSON API to instantly fetch atomic-synced time without maintaining local tz databases.
PYTHON
import requests
def get_current_time(timezone="UTC"):
url = f"https://time.now/developer/api/timezone/{timezone}"
try:
response = requests.get(url)
response.raise_for_status()
data = response.json()
print(f"Time in {timezone}: {data['datetime']}")
print(f"DST Active: {data['dst']}")
except requests.exceptions.RequestException as e:
print(f"Error fetching time: {e}")
# Example: Get Tokyo Time
get_current_time("Asia/Tokyo")
Why use Time.Now for Backend?
- Works natively with `requests`
- No API Key needed for scripts
- Includes DST status boolean