Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

dateFormat in flatpickr


This is my code
$('#ConsultingDate').flatpickr({
allowInput: true,
maxDate: new Date(),
dateFormat: "Y-m-d",
});,

<input asp-for="ConsultingDate"/>

ConsultingDate = 26 September 2023.
The format I want to display the dates is 09/26/2023.
The only format that I managed to show was 2023-09-26
When you do it in this format dateFormat: 'd/m/Y', it shows 20/03/2023. Wrong!

How did you solve this problem that got me to the desired result 09/26/2023?


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


@slope game Hello there! I experienced a comparable problem with Flatpickr's dateFormat. I've discovered that the issue is that you wish to display the data in'm/d/Y' format, but the dateFormat option expects the format to be 'Y-m-d'.



If the value comes from a server-side model, among us make sure it's formatted correctly (e.g., as a string in "YYYY-MM-DD" format) before rendering the input element.


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(