Files
30-seconds-of-code/snippets/json-to-date.md
2017-12-16 14:31:04 +02:00

326 B

JSON to date

Use Date(), to convert dates in JSON format to readable format (dd/mm/yyyy).

const jsonToDate = arr => {
  const dt = new Date(parseInt(arr.toString().substr(6)));
  return `${ dt.getDate() }/${ dt.getMonth() + 1 }/${ dt.getFullYear() }`
};
// jsonToDate(/Date(1489525200000)/) -> "14/3/2017"