How set the datepicker in moment.js to yyyy-mm-dd?

Member

by denis , in category: Javascript , a year ago

How set the datepicker in moment.js to yyyy-mm-dd?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by scotty_walker , a year ago

@denis 

To set the format of the datepicker in moment.js to "yyyy-mm-dd", you can use the format() method. Here's an example:

1
2
3
4
5
6
7
// Assuming you have a datepicker element with the id "datepicker"
var datepicker = document.getElementById("datepicker");

// Set the date format to "yyyy-mm-dd"
$(datepicker).datepicker({
  format: "yyyy-mm-dd"
});


Make sure you have the datepicker library (e.g., jQuery UI datepicker) included in your project and that you have already imported the necessary JavaScript files.