I got this JSON response by using OpenWeather's API:
{
"coord": {
"lon": 139.69,
"lat": 35.69
},
"weather": [
{
"id": 803,
"main": "Clouds",
"description": "broken clouds",
"icon": "04d"
}
],
"base": "stations",
"main": {
"temp": 306.63,
"feels_like": 311.16,
"temp_min": 304.82,
"temp_max": 308.15,
"pressure": 1011,
"humidity": 63
},
"visibility": 10000,
"wind": {
"speed": 3.1,
"deg": 140
},
"clouds": {
"all": 75
},
"dt": 1598419499,
"sys": {
"type": 1,
"id": 8077,
"country": "JP",
"sunrise": 1598386129,
"sunset": 1598433465
},
"timezone": 32400,
"id": 1850144,
"name": "Tokyo",
"cod": 200
}
I wish to get the current time from that city by using timezone
property or another property. Is it possible? how?
A way to get current time of the city using the timezone
you've got from the API can be as following:
DateTime.now().add(Duration(seconds: timezone - DateTime.now().timeZoneOffset.inSeconds))
You will get a DateTime
object from here.