format date / Date () / of Angular

0

I have the calendar and it generates a piece of information that shows me this way:

/Date(1513828800000)/

in the view I'm getting the date from:

<input type="date" class="form-control" id="txtvalor" ng-model="datos.Fecha" placeholder="Fecha" />

try this way

 <td scope="row">{{datos.Fecha | date:'dd-MM-yyyy'}}</td>

not like this either:

<td scope="row">{{ datos.Fecha | date : format : timezone}}</td>

Do you know another way?

    
asked by Rodrigo Rodriguez 21.12.2017 в 14:27
source

2 answers

2

if you have others try the list of numbers 1513828800000 and give you / Date (1513828800000) / make a substr:

{{datos.Fecha.substr(6,13) | date:'dd/MM/yyyy'}}

will always reach that number of numbers "always filled with 0 example: 03/13/2017 "

    
answered by 21.12.2017 / 20:16
source
1

the 'date' filter of angularJS parse information type 'Long'. Therefore, make sure that:

  • The data obtained from 'data.Date' is a value of the date in milliseconds (Long), for example: 1288323623006 (Oct 28, 2010 10:40:23 PM). That is not indefinite or null.

  • In the second way that you tried it, you should have defined in the scope the variables of 'format' and 'timezone'. For example:

    $scope.format = 'dd-MM-yyyy';
    $scope.timezone = '+0430;
    

As an example, I leave you the following (obtained from docs.angularjs.org ):

{{1288323623006 | date:'medium'}}: Oct 28, 2010 10:40:23 PM

You can follow the official documentation of angularJS: filterDate .

UPDATED:

Apparently it is a cast made by Microsoft JSON, a solution could be this:

var fecha = "/Date(1224043200000)/";
console.log(new Date(parseInt(fecha.substr(6))));
    
answered by 21.12.2017 в 15:52