Change date format in angular datetime picker

This article explains how to format the date in angularjs datetime piker.

Note: for better understanding of this article please ready my previous article on angular datetime picker AngularJS DateTime Picker

For formatting date in angular datetime picker we have to use the angular-date-time-input directive.

First, add the dateTimeInput.js file in your project from the following url.

https://github.com/dalelotts/angular-date-time-input/blob/master/src/dateTimeInput.js

Add dateTimeInput module as a dependency to your application module.

var myModule = angular.module('MyApp', ['ui.dateTimeInput'])

Finally apply the date-time-input directive in your form element where you are showing the date.

<input data-date-time-input="YYYY-MM-DD" />

The value of the date-time-input attribute is the format the date values will be displayed.

This way we can change the date format of angular datetime picker.

For more posts on AngularJS visit: AngularJS

No comments:

Post a Comment