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.

3
  • 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. Commented Feb 15, 2023 at 19:08
  • I posted an update. It did work, but I needed to restart the build for some reason (not sure why)... Thanks! Commented Feb 15, 2023 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. It's hard to say why it didn't work in your case without seeing your code. Commented Feb 15, 2023 at 19:38

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.