If you are not having an input field, rather just want to display a string date with a proper formatting, you can simply go for:
<label ng-bind="formatDate(date) | date:'MM/dd/yyyy'"></label>
and in the js file use:
// @Function
// Description : Triggered while displaying expiry date
$scope.formatDate = function(date){
var dateOut = new Date(date);
return dateOut;
};
This will convert the date in string to a new date object in javascript and will display the date in format MM/dd/yyyy.
Output: 12/15/2014
Edit
If you are using a string date of format "2014-12-19 20:00:00" string format (passed from a PHP backend), then you should modify the code to the one in: https://mcmap.net/q/151845/-javascript-date-object-issue-in-safari-and-ie
Adding on further
From javascript you can set the code as:
$scope.eqpCustFields[i].Value = $filter('date')(new Date(dateValue),'yyyy-MM-dd');
that is in case you already have a date with you, else you can use the following code to get the current system date:
$scope.eqpCustFields[i].Value = $filter('date')(new Date(),'yyyy-MM-dd');
For more details on date Formats, refer : https://docs.angularjs.org/api/ng/filter/date
ui-date-format="mm/dd/yyyy"
altogether? It looks like the default behavior without this option is what you want. – Colorado$formatters
and$parsers
per this answer solved my similar problem. – Allemande