简体   繁体   中英

How do I format datetimepicker visible value

I want the selected date to be returned in a more readable format for the user. I already tried solutions suggested online

$(document).ready(function() {
  $('#startDate').datetimepicker({
    format: 'dd/mm/yyyy'
  });

  $('#endDate').datetimepicker({
    format: 'dd/mm/yyyy'
  });
});

The selected date currently is shown to the user as:

0202/0707/19191919

This was answered simply by changing to format: 'd/m/Y' . Thanks to Amit

Try changing the format like this, because datetimepicker takes format string as momentjs standards.

$(document).ready(function() {
  $('#startDate').datetimepicker({
    format: 'DD/MM/YYYY'
  });

  $('#endDate').datetimepicker({
    format: 'DD/MM/YYYY'
  });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM