umesh pandey
umesh pandey

Reputation: 116

Convert given time from UTC to IST?

After using OpenWeatherAPI:

It send output like:

'sys': {'country': 'IN',
'id': 7809,
'message': 0.0086,
'sunrise': 1530403006,
'sunset': 1530453167,
'type': 1},

Timezone of sunrise and sunset's shown time in output is UTC. How to get actual time of sunrise and sunset either on UTC or IST?

Upvotes: 0

Views: 3352

Answers (1)

Simas Joneliunas
Simas Joneliunas

Reputation: 3138

you can do it by using dateutil:

from datetime import datetime
from dateutil import tz

utc = datetime.fromtimestamp(1530403006)
itc_time= utc.astimezone(tz.gettz('ITC'))
print(itc_time)

returns 2018-07-01 07:56:46+08:00

Upvotes: 1

Related Questions