from datetime import datetime from pytz import timezone from babel.dates import format_time import pytz FORMAT = '%H:%M / %d-%m-%Y' MONTHS = ('Jan.', 'Feb.', 'Mar.', 'April.', 'May.', 'June.', 'July.', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.') # dummy function if you want to use i18 later and the real _ translation def _(dummy): return dummy def format_datetime_human(to_format, locale='en', timezoneinfo='Asia/Calcutta'): import datetime as DT import pytz utc = pytz.utc to_format = DT.datetime(int(to_format.year), int(to_format.month), int(to_format.day), int(to_format.hour), int(to_format.minute)) utc_date = utc.localize(to_format) tzone = pytz.timezone(timezoneinfo) tzone_date = utc_date.astimezone(tzone) month = MONTHS[int(tzone_date.month) - 1] time_str = format_time(tzone_date, 'H:mm') date_str = '{0} {1}'.format(tzone_date.day, _(month)) return "{0} {1}".format(date_str, time_str)