我正在开发自己的项目,这是一个天气预报网站。但是,从 DarkSky 加载 JSON 后,我遇到了日期、时间和温度格式的一些问题。 下面是我从 DarkSky 获取 JSON 后的数据:
apparentTemperatureHigh: 88.48
apparentTemperatureHighTime: 1527627600
apparentTemperatureLow: 69.66
apparentTemperatureLowTime: 1527674400
apparentTemperatureMax: 88.48
apparentTemperatureMaxTime: 1527627600
apparentTemperatureMin: 68.31
apparentTemperatureMinTime: 1527573600
cloudCover: 0.88
dewPoint: 68.69
humidity: 0.83
icon: "fog"
moonPhase: 0.51
ozone: 318.12
precipIntensity: 0.0003
precipIntensityMax: 0.0018
precipIntensityMaxTime: 1527649200
precipProbability: 0.15
precipType: "rain"
pressure: 1016.16
summary: "Foggy in the morning."
sunriseTime: 1527587293
sunsetTime: 1527640035
temperatureHigh: 84.29
temperatureHighTime: 1527627600
temperatureLow: 68.49
temperatureLowTime: 1527674400
temperatureMax: 84.29
temperatureMaxTime: 1527627600
temperatureMin: 67.36
temperatureMinTime: 1527573600
time: 1527566400
uvIndex: 7
uvIndexTime: 1527613200
visibility: 6.25
windBearing: 146
windGust: 11.99
windGustTime: 1527645600
windSpeed: 2.44
所以,我不知道如何将 1527566400
时间转换为我可以读取的时间。另外,我混淆了 TemperatureHighTime
和 TemperatureLowTime
。
您能给我提示如何将这些值格式化为可读值吗?我将不胜感激任何帮助。
最佳答案
给出的时间看起来像 UNIX 时间 - 自 1970 年 1 月 1 日 00:00 UTC 以来的秒数。
大多数高级编程语言都具有从 UNIX 时间转换为更易读的值的功能 - here's a previous answer that gives instructions .
关于javascript - 使用 Javascript 加载 DarkSky 后格式化日期、时间和温度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50591570/