'How can I get day name from string date '22 May 2022' in flutter
I am a beginner in Flutter, I want to get day name [like Sunday]
from a date, date i am getting from api which is basically a string like '22 May 2022'
How can i get that from this date '22 May 2022'
? Can anyone help me? any help should be appreciated
I have tried this but not working for me.
Solution 1:[1]
Try this :
final dateName = DateFormat('EEEE').format(DateFormat("DD MMMM yyyy").parse('22 May 2022'));
Solution 2:[2]
final dateName = DateFormat('MEd').format(DateFormat("DD MMMM yyyy").parse('22 May 2022'));
You can check there all format date https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | manhtuan21 |
Solution 2 | Zozo |