From b61b87f0de60ceeafd7b169d44c060058efb8cda Mon Sep 17 00:00:00 2001 From: Huseyin Sekmenoglu Date: Fri, 15 Dec 2017 11:35:57 +0300 Subject: [PATCH 1/2] Create convert-json-date.md --- snippets/convert-json-date.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 snippets/convert-json-date.md diff --git a/snippets/convert-json-date.md b/snippets/convert-json-date.md new file mode 100644 index 000000000..3c0d276dc --- /dev/null +++ b/snippets/convert-json-date.md @@ -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 + ``` + From 9809b65b2616801e69440e7a0cd2413c6616746b Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sat, 16 Dec 2017 14:28:58 +0200 Subject: [PATCH 2/2] Update and rename convert-json-date.md to json-to-date.md --- snippets/{convert-json-date.md => json-to-date.md} | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename snippets/{convert-json-date.md => json-to-date.md} (64%) diff --git a/snippets/convert-json-date.md b/snippets/json-to-date.md similarity index 64% rename from snippets/convert-json-date.md rename to snippets/json-to-date.md index 3c0d276dc..7e5efcdc7 100644 --- a/snippets/convert-json-date.md +++ b/snippets/json-to-date.md @@ -1,7 +1,5 @@ -### Convert Json Date +### JSON to date -Convert dates coming from ajax as json to readable format -Example: converts "/Date(1489525200000)/" to "15/2/2017" ```js cconst JsonToDate = arr =>