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.
Asked
Active
Viewed 55 times
-2
-
Welcome on SO. Please do some research before posting here – Laurent S. Jul 04 '14 at 11:08
-
Thanks @R.T. you are right, it worked. – Gaurav Jul 04 '14 at 13:20
2 Answers
0
Simple
var date = new Date("Wed, 2 Jul 2014 19:18:01 +0530");
Rahul Tripathi
- 161,154
- 30
- 262
- 319
-
1+1 because I think that it's a working example and score of -1 is not right – faby Jul 04 '14 at 13:28
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