-2

I have the string like "Wed, 2 Jul 2014 19:18:01 +0530", and I want to convert this string into a javascript date object, Please suggest me a best way to do this.

Gaurav
  • 3
  • 1

2 Answers2

0

Simple

var date = new Date("Wed, 2 Jul 2014 19:18:01 +0530");
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
0

try this solution

 var time= Date.parse("Wed, 2 Jul 2014 19:18:01 +0530"); //number of milliseconds since January 1, 1970, 00:00:00 UTC
 var date = new Date(time);

refer here for documentation about Date.parse,
here for Converting milliseconds to a date.

also

var date = new Date("Wed, 2 Jul 2014 19:18:01 +0530");

should work

Community
  • 1
  • 1
faby
  • 7,394
  • 3
  • 27
  • 44