0

I want to format a JSON date.I search and I found this link. Json Date When I use @Roy's ans mention in above question I get a result in format:

Mon Jul 16 2012 14:10:42 GMT+0545 (Nepal Standard Time)

but I want a result in format:

Mon Jul 16 2012 14:10:42

How can I avoid unnecessary part to get desire result.Thanks.

Community
  • 1
  • 1
4b0
  • 21,981
  • 30
  • 95
  • 142

1 Answers1

0
var dt = new Date().toString();
console.log(dt); // Mon Jul 16 2012 15:21:09 GMT+0530 (India Standard Time)
dt = dt.substr(0, dt.indexOf('GMT'));
console.log(dt); // Mon Jul 16 2012 15:21:09 

From the looks of it, this seems to be what you want....

Amith George
  • 5,806
  • 2
  • 35
  • 53