0

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: https://github.com/urish/angular-moment 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) {
    pikaday.setConfig({
        // numberOfMonths: 1,
        format: "YYYY-MM-DD"
    });
}])

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

4

1 回答 1

1

您不需要使用角力矩。

您应该做的是在包含 pickaday.js 之前在您的 HTML 页面中包含 momentjs 脚本:

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js"></script>

就像在这个例子中一样。Pickaday 格式选项将起作用。

于 2016-08-18T18:52:00.363 回答