zaagan
6/29/2019 - 3:53 PM

Date Conversion

Date Conversion

var d = new Date('July 12, 2017 07:22:13')

d.toString() 
/*  "Wed Jul 12 2017 07:22:13 GMT+0545 (Nepal Time)"  */

d.toTimeString() 
/*  "07:22:13 GMT+0545 (Nepal Time)"  */

date.toUTCString() 
/*  "Wed, 12 Jul 2017 01:37:13 GMT"  */

d.toDateString() 
/*  "Wed Jul 12 2017"  */

d.toISOString() 
/*  "2017-07-12T01:37:13.000Z"  (ISO 8601 format) */

d.toLocaleString() 
/*  "7/12/2017, 7:22:13 AM"  */

d.toLocaleTimeString()	
/*  "7:22:13 AM"  */

d.toLocaleDateString()
/*  "7/12/2017"  */

d.toJSON()
/*  "2017-07-12T01:37:13.000Z"  */


new Date(parseInt(yourDate.replace(/[^0-9 +]/g, '')))
/*
  Input:  "/Date(1575261857557)/"  =>
  Output: Date Mon Dec 02 2019 10:29:17 GMT+0545 (Nepal Time)
*/