Home > Back-end >  How do I get the names of months and years from a DateTime list into a map?
How do I get the names of months and years from a DateTime list into a map?

Time:10-12

How do I get the names of months and years from a DateTime list into a map?

For example: i have list of DateTime: [22.01.2022, 24.01.2022, 15.02.2022, 29.03.2023]

I have to get on the way out:

{
 "jan22" = "January 2022",
 "feb22" = "February 2022"
 "mar23" = "March 2023"
}

CodePudding user response:

Lets assume your List is:

List<DateTime> dates = [
    DateTime(2022, 07, 01),
    DateTime(2022, 08, 04),
  ];

With enter image description here

  • Related