I am struggling with the code below:
function Ctrl($scope)
{
$scope.dt = new Date('2012-07-16T00:00:00');
var format =
{
day: '2-digit',
month: '2-digit',
year: 'numeric'
};
$scope.dateTimeFormatter = Intl.DateTimeFormat('es-es', format);
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app ng-controller="Ctrl">
In: {{dt}} <br/>
Angular: {{dt | date:'yyyy-MM-dd HH:mm:ss Z'}}
<div style="background-color:lightgreen;">
This is working: {{dateTimeFormatter.format(dt)}}
</div>
<div style="background-color:rgb(251, 123, 89);">
This is not working: {{dateTimeFormatter.format(Date.parse('2012-07-16T00:00:00'))}}
</div>
</div>
Can anyone help me figure out what I might be doing incorrectly?
Why does the green line function as expected while the red one doesn't?