Reputation: 298
The information comes to me through a service which arrives with a negative sign and I must format dd/MM/yyyy
real date = 27/10/1962
var date = "/Date(-226612800000)/"; //This is the date that arrives for the service
$scope.Date = new Date(parseInt(date.match(/\/Date\(([0-9]*)\)\//)[1]));
alert($scope.Date);
the negative sign is causing me trouble I have to work everything inside the AngularJS controller
Upvotes: 0
Views: 23
Reputation: 48968
Add the -
character to the matcher:
var date = "/Date(-226612800000)/"; //This is the date that arrives for the service
var date2 = new Date(parseInt(date.match(/\/Date\(([-0-9]*)\)\//)[1]));
console.log(date2);
Upvotes: 1