gpt4 book ai didi

android - 如何从 flutter 中的毫秒获取时间

转载 作者:行者123 更新时间:2023-12-03 03:16:23 26 4
gpt4 key购买 nike

我想从 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com