我想从 openweathermap.org API 获取小时和分钟。在这个API中,日落的值为1570103293。现在我想从这个值获取日落时间。这是 API 的 JSON 值:
{
"coord": {
"lon": -122.08,
"lat": 37.39
},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01d"
}
],
"base": "stations",
"main": {
"temp": 296.71,
"pressure": 1013,
"humidity": 53,
"temp_min": 294.82,
"temp_max": 298.71
},
"visibility": 16093,
"wind": {
"speed": 1.5,
"deg": 350
},
"clouds": {
"all": 1
},
"dt": 1560350645,
"sys": {
"type": 1,
"id": 5122,
"message": 0.0139,
"country": "US",
"sunrise": 1560343627,
"sunset": 1560396563
},
"timezone": -25200,
"id": 420006353,
"name": "Mountain View",
"cod": 200
}
最佳答案
您可以使用DateTime.fromMillisecondsSinceEpoch()
。但'1560343627'是秒数(不是毫秒),所以你需要将它乘以1000:
DateTime.fromMillisecondsSinceEpoch(1560343627*1000)
关于android - 如何从 flutter 中获取毫秒时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58222090/