Create convert-json-date.md

This commit is contained in:
Huseyin Sekmenoglu
2017-12-15 11:35:57 +03:00
committed by GitHub
parent 66702ee476
commit b61b87f0de

View File

@ -0,0 +1,14 @@
### Convert Json Date
Convert dates coming from ajax as json to readable format
Example: converts "/Date(1489525200000)/" to "15/2/2017"
```js
cconst JsonToDate = arr =>
{
const dt = new Date(parseInt(arr.toString().substr(6)));
return dt.getDate() + '/' + dt.getMonth() + '/' + dt.getFullYear();
};
// JsonToDate(/Date(1489525200000)/) -> 15/2/2017
```