I want to search for a particular date in an API in the format of "2019-03-27" but in the API the format is "2019-03-27 19:00:00". so there any way I can do it without parsing. I tried using the substring function to delete the last 8 char but it didn't work. API Link: https://samples.openweathermap.org/data/2.5/forecast/hourly?q=London,us&appid=b6907d289e10d714a6e88b30761fae22
Asked
Active
Viewed 146 times
2 Answers
0
Use this code for example:
final dtTest = DateTime.parse('2020-11-28');
final dtFromApi = DateTime.parse(map['dt_text']);
if (dtFromApi.day == dtTest.day && dtFromApi.month == dtTest.month && dtFromApi.year == dtTest.year) {
// found
}

BambinoUA
- 6,126
- 5
- 35
- 51
0
You can split date time string by space then pick first pair then parse it.
print(DateTime.parse('2019-03-27 19:00:00'.split(' ')));

TheMisir
- 4,083
- 1
- 27
- 37