1

I am using intl pakage's DateFormat class to format dates with a format like this:

_standardDateFormat = DateFormat('MMM dd, yyyy');

This produces strings like Feb 01, 2023.

How can I have the date without the prefix of 0 when it's a single-digit date? I would like to show Feb 1, 2023. I have tried d, dd, c but they all render with the prefixed 0.


If it's a double-digit date, I would of course like to show both digits: Mar 13, 2023.

or9ob
  • 2,313
  • 4
  • 25
  • 45
  • 1
    A single `d` should work (`DateFormat('MMM d, yyyy')`), and it works when I try it. Can you double-check that it is not working for you? If not, please post a minimal, reproducible example. – jamesdlin Feb 15 '23 at 19:08
  • I posted an update. It did work, but I needed to restart the build for some reason (not sure why)... Thanks! – or9ob Feb 15 '23 at 19:30
  • If you mean that you didn't observe any change when doing a hot reload, then there are [a variety of reasons why hot reload might not include a change](https://docs.flutter.dev/development/tools/hot-reload#special-cases). It's hard to say why it didn't work in your case without seeing your code. – jamesdlin Feb 15 '23 at 19:38

1 Answers1

0

Update: the single d format is indeed working, but I needed to restart flutter build to see the effect (not sure why).

or9ob
  • 2,313
  • 4
  • 25
  • 45