Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何检索只有00:00:00时间的数据?_Javascript_Json - Fatal编程技术网

Javascript 如何检索只有00:00:00时间的数据?

Javascript 如何检索只有00:00:00时间的数据?,javascript,json,Javascript,Json,我想建立一个网站的天气预报与反应。我使用OpenWeatherAPI。对于5天预报功能,openweather每3小时更新一次数据。如果我想每天显示天气信息(直到5天后),如果我想在JavaScript中只获取00:00:00时间的数据,如何过滤数据?我不想一直展示它 我想要的示例(2021-06-07 00:00:00、2021-06-08 00:00:00等) 下面是API的响应 { "cod":"200", "message&q

我想建立一个网站的天气预报与反应。我使用OpenWeatherAPI。对于5天预报功能,openweather每3小时更新一次数据。如果我想每天显示天气信息(直到5天后),如果我想在JavaScript中只获取00:00:00时间的数据,如何过滤数据?我不想一直展示它

我想要的示例(2021-06-07 00:00:00、2021-06-08 00:00:00等)

下面是API的响应

{
   "cod":"200",
   "message":0,
   "cnt":10,
   "list":[
      {
         "dt":1623067200,
         "main":{
            "temp":303.17,
            "feels_like":309.24,
            "temp_min":298.78,
            "temp_max":303.17,
            "pressure":1007,
            "sea_level":1007,
            "grnd_level":1006,
            "humidity":74,
            "temp_kf":4.39
         },
         "weather":[
            {
               "id":500,
               "main":"Rain",
               "description":"hujan rintik-rintik",
               "icon":"10n"
            }
         ],
         "clouds":{
            "all":40
         },
         "wind":{
            "speed":1.08,
            "deg":47,
            "gust":1.51
         },
         "visibility":10000,
         "pop":0.7,
         "rain":{
            "3h":1.1
         },
         "sys":{
            "pod":"n"
         },
         "dt_txt":"2021-06-07 12:00:00"
      },
      {
         "dt":1623078000,
         "main":{
            "temp":301.25,
            "feels_like":305.5,
            "temp_min":297.4,
            "temp_max":301.25,
            "pressure":1009,
            "sea_level":1009,
            "grnd_level":1009,
            "humidity":80,
            "temp_kf":3.85
         },
         "weather":[
            {
               "id":500,
               "main":"Rain",
               "description":"hujan rintik-rintik",
               "icon":"10n"
            }
         ],
         "clouds":{
            "all":60
         },
         "wind":{
            "speed":1.33,
            "deg":230,
            "gust":1.48
         },
         "visibility":10000,
         "pop":0.79,
         "rain":{
            "3h":1.47
         },
         "sys":{
            "pod":"n"
         },
         "dt_txt":"2021-06-07 15:00:00"
      },
      {
         "dt":1623088800,
         "main":{
            "temp":298.69,
            "feels_like":299.6,
            "temp_min":296.45,
            "temp_max":298.69,
            "pressure":1010,
            "sea_level":1010,
            "grnd_level":1008,
            "humidity":88,
            "temp_kf":2.24
         },
         "weather":[
            {
               "id":500,
               "main":"Rain",
               "description":"hujan rintik-rintik",
               "icon":"10n"
            }
         ],
         "clouds":{
            "all":80
         },
         "wind":{
            "speed":1.91,
            "deg":254,
            "gust":3.05
         },
         "visibility":10000,
         "pop":0.68,
         "rain":{
            "3h":0.12
         },
         "sys":{
            "pod":"n"
         },
         "dt_txt":"2021-06-07 18:00:00"
      },
      {
         "dt":1623099600,
         "main":{
            "temp":295.71,
            "feels_like":296.45,
            "temp_min":295.71,
            "temp_max":295.71,
            "pressure":1009,
            "sea_level":1009,
            "grnd_level":1006,
            "humidity":93,
            "temp_kf":0
         },
         "weather":[
            {
               "id":804,
               "main":"Clouds",
               "description":"awan mendung",
               "icon":"04n"
            }
         ],
         "clouds":{
            "all":100
         },
         "wind":{
            "speed":1.4,
            "deg":223,
            "gust":1.83
         },
         "visibility":10000,
         "pop":0.09,
         "sys":{
            "pod":"n"
         },
         "dt_txt":"2021-06-07 21:00:00"
      },
      {
         "dt":1623110400,
         "main":{
            "temp":295.86,
            "feels_like":296.48,
            "temp_min":295.86,
            "temp_max":295.86,
            "pressure":1010,
            "sea_level":1010,
            "grnd_level":1007,
            "humidity":88,
            "temp_kf":0
         },
         "weather":[
            {
               "id":804,
               "main":"Clouds",
               "description":"awan mendung",
               "icon":"04d"
            }
         ],
         "clouds":{
            "all":100
         },
         "wind":{
            "speed":1.24,
            "deg":201,
            "gust":1.66
         },
         "visibility":10000,
         "pop":0.06,
         "sys":{
            "pod":"d"
         },
         "dt_txt":"2021-06-08 00:00:00"
      },
      {
         "dt":1623121200,
         "main":{
            "temp":301.75,
            "feels_like":304.09,
            "temp_min":301.75,
            "temp_max":301.75,
            "pressure":1011,
            "sea_level":1011,
            "grnd_level":1008,
            "humidity":64,
            "temp_kf":0
         },
         "weather":[
            {
               "id":804,
               "main":"Clouds",
               "description":"awan mendung",
               "icon":"04d"
            }
         ],
         "clouds":{
            "all":100
         },
         "wind":{
            "speed":0.93,
            "deg":142,
            "gust":1.98
         },
         "visibility":10000,
         "pop":0,
         "sys":{
            "pod":"d"
         },
         "dt_txt":"2021-06-08 03:00:00"
      },
      {
         "dt":1623132000,
         "main":{
            "temp":304.02,
            "feels_like":307.02,
            "temp_min":304.02,
            "temp_max":304.02,
            "pressure":1009,
            "sea_level":1009,
            "grnd_level":1007,
            "humidity":57,
            "temp_kf":0
         },
         "weather":[
            {
               "id":804,
               "main":"Clouds",
               "description":"awan mendung",
               "icon":"04d"
            }
         ],
         "clouds":{
            "all":100
         },
         "wind":{
            "speed":1.19,
            "deg":68,
            "gust":1.58
         },
         "visibility":10000,
         "pop":0,
         "sys":{
            "pod":"d"
         },
         "dt_txt":"2021-06-08 06:00:00"
      },
      {
         "dt":1623142800,
         "main":{
            "temp":304.15,
            "feels_like":308,
            "temp_min":304.15,
            "temp_max":304.15,
            "pressure":1007,
            "sea_level":1007,
            "grnd_level":1004,
            "humidity":60,
            "temp_kf":0
         },
         "weather":[
            {
               "id":803,
               "main":"Clouds",
               "description":"awan pecah",
               "icon":"04d"
            }
         ],
         "clouds":{
            "all":58
         },
         "wind":{
            "speed":2.67,
            "deg":51,
            "gust":2.18
         },
         "visibility":10000,
         "pop":0.03,
         "sys":{
            "pod":"d"
         },
         "dt_txt":"2021-06-08 09:00:00"
      },
      {
         "dt":1623153600,
         "main":{
            "temp":298.71,
            "feels_like":299.65,
            "temp_min":298.71,
            "temp_max":298.71,
            "pressure":1010,
            "sea_level":1010,
            "grnd_level":1007,
            "humidity":89,
            "temp_kf":0
         },
         "weather":[
            {
               "id":500,
               "main":"Rain",
               "description":"hujan rintik-rintik",
               "icon":"10n"
            }
         ],
         "clouds":{
            "all":62
         },
         "wind":{
            "speed":0.69,
            "deg":45,
            "gust":1.05
         },
         "visibility":10000,
         "pop":0.3,
         "rain":{
            "3h":0.55
         },
         "sys":{
            "pod":"n"
         },
         "dt_txt":"2021-06-08 12:00:00"
      },
      {
         "dt":1623164400,
         "main":{
            "temp":297.75,
            "feels_like":298.69,
            "temp_min":297.75,
            "temp_max":297.75,
            "pressure":1012,
            "sea_level":1012,
            "grnd_level":1009,
            "humidity":93,
            "temp_kf":0
         },
         "weather":[
            {
               "id":500,
               "main":"Rain",
               "description":"hujan rintik-rintik",
               "icon":"10n"
            }
         ],
         "clouds":{
            "all":100
         },
         "wind":{
            "speed":1.47,
            "deg":244,
            "gust":1.54
         },
         "visibility":10000,
         "pop":0.61,
         "rain":{
            "3h":0.38
         },
         "sys":{
            "pod":"n"
         },
         "dt_txt":"2021-06-08 15:00:00"
      }
   ],
   "city":{
      "id":1214520,
      "name":"Kota Medan",
      "coord":{
         "lat":3.5833,
         "lon":98.6667
      },
      "country":"ID",
      "population":0,
      "timezone":25200,
      "sunrise":1623021281,
      "sunset":1623065636
   }
}

提前感谢。

假设
数据是您的JS对象

let filtered=[];
for(数据的var行。列表){
if(row.dt_txt.endsWith('00:00:00')){
过滤。推送(行)
}
}
这将创建一个新数组,遍历您的值列表,如果
dtu text
以00:00:00结束,则当前行将添加到您的
filtered
数组中