How do you format the day of the month to say “11th”, “21st” or “23rd” in Dart?
dart, date, internationalization
Solution
Try out this package, Jiffy, inspired by momentjs.
Just simply add the `do` date pattern. See below
Jiffy.parseFromList([2014, 4, 23]).format("EEEE MMMM do, yyyy"); // Wednesday April 23rd, 2014
You can also add your DateTime object
Jiffy.parseFromDateTime(DateTime(2014, 4, 23)).format("EEEE MMMM do, yyyy"); // Wednesday April 23rd, 2014
Problem
I have a date and want to display the date with the suffix th, st, rd, etc. Here is my dart code. ``` int year = date.year; int month = date.month; int day = date.day; DateTime dateSelected = new DateTime(year, month, day); var formatter = new DateFormat('EEEE MMMM dd, yyyy'); displayDate = formatter.format(dateSelected); ``` This displays dates as "Wednesday April 23, 2014" for example, but I need "Wednesday April 23rd, 2014". I'm using the intl package. import 'package:intl/intl.dart';