Create convert-json-date.md
This commit is contained in:
committed by
GitHub
parent
66702ee476
commit
b61b87f0de
14
snippets/convert-json-date.md
Normal file
14
snippets/convert-json-date.md
Normal 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
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user