artan artan - 2 months ago 36
AngularJS Question

How to change format for the date in angular pikaday

I am using pikaday library for my angularjs app for datepicker but can't change the format for the date and my html element looks like this:

<input pikaday="clas.myPicker" class="form-control" on-select="clas.onPikadaySelect(pikaday)">

The format shows as: Aug 30 2016, I would want it 2016-08-30.

I see that I have to use moment.js, I tried this: but my angularjs version is 1.2.16 quite old and I cannot install it.

I also have this on the app config in angularjs:

.config(['pikadayConfigProvider', function (pikaday) {
// numberOfMonths: 1,
format: "YYYY-MM-DD"

Is there any other option how do I change the format of date?


You don't need to use angular-moment.

What you should do is to include momentjs script on your HTML page before you include pickaday.js:

<script type="text/javascript" src=""></script>

Like in this example. Pickaday format option will work.