0

I have this code

$(function() {
    $( "#datepicker" ).datepicker();
  });

And result is a date like this 23/12/16 but i need to get format 23-12-2016 How I can do this?

0

3 Answers 3

0
$(function() {
    $( "#datepicker" ).datepicker({
     format: 'dd-mm-yyyy'
    });
  });
Sign up to request clarification or add additional context in comments.

Comments

0

Pass "dd-mm-yy" as dateFormat.

$( "#datepicker" ).datepicker({ dateFormat: "dd-mm-yy" })

Comments

0

Here we go:

Try to reconstruct DateTime string as like this:

var dateObj = $("#datepicker").val();
var newDate = new Date(dateObj );
var formattedString = [newDate.Date(),newDate.Month()+1, newDate.getFullYear()].join("-");
alert(formattedString );

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.