How to use 'how to pass date in json format' in JavaScript

Every line of 'how to pass date in json format' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
3function parseJsonDate(value) {
4 var a;
5
6 if (typeof value === 'string') {
7 a = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
8 if (a) {
9 return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
10 +a[5], +a[6]));
11 }
12 }
13 return value;
14};

Related snippets