Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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 create JavaScript Date object from date string?
To create a date object from date string, just add the string like this −
var date = new Date(2018,1,1);
Example
You can try to run the following code to create date object from date string. Here, the month is indexed as 0 for Jan, 1 for Feb, etc in JavaScript −
<html>
<head>
<title>JavaScript Dates</title>
</head>
<body>
<script>
var date;
date = new Date(2018,0,1);
document.write("Current Date: "+date);
</script>
</body>
</html>
Output
Current Date: Mon Jan 01 2018 00:00:00 GMT+0530 (India Standard Time)
Advertisements