killerbng icon

Custom Clocks - Console App

killerbng | PRO | 03/05/15 02:13:31 PM UTC | 0 ⭐ | 376 👁️ | Never ⏰ | []
Python |

690 B

|

None

|

0 👍

/

0 👎

import requests
import json
from datetime import datetime
from pytz import timezone
import pytz
 
def get_time(tz):
    now = datetime.now()
    fmt = '%Y-%m-%d %H:%M:%S'
    eastern = timezone('US/Eastern')
    new_tz = timezone(tz)
    loc_dt = eastern.localize(datetime(now.year, now.month, now.day, now.hour, now.minute, now.second))
    new_dt = loc_dt.astimezone(new_tz)
    new_dt.strftime(fmt)
    new_dt = str(new_dt)
    new_dt = new_dt.replace("None", "")
    return new_dt
 
 
print("East Coast US: " + str(get_time('US/Eastern'))+"\n")
print("Moscow, Russia: " + str(get_time('Europe/Moscow'))+"\n")
print("Melbourne, Australia: " + str(get_time('Australia/Melbourne'))+"\n")

Comments