 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to convert a string in to date object in JavaScript?
To convert a string in to date object Date() method should be used. This method creates a date instance that represents a single moment in time in a platform-independent format.
Example
In the following example a string named "str" is initially parsed using JSON.parse() method and then converted in to date object using Date() method.
<html> <body> <script>    var str = '{"name":"Ram", "DOB":"1980-11-1", "country":"India"}';    var dateObj = JSON.parse(str);    dateObj.DOB = new Date(dateObj.DOB);    document.write(dateObj.DOB); </script> </body> </html>  Output
Thu Nov 01 0198 00:00:00 GMT+0553 (India Standard Time)
Advertisements
 