作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想从 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/
我是一名优秀的程序员,十分优秀!