

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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)
- Related Questions & Answers
- How to create Date object from String value in Java?
- How to create a Date object in JavaScript?
- How do you create a date object from a date in Swift xcode?
- How to convert a Python date string to a date object?
- How to create date object in Java?
- How to convert a JavaScript date object to a string?
- How to convert a string in to date object in JavaScript?
- How do you create a date object from a date in Swift xcode in iOS?
- How to clone a Date object in JavaScript?
- How to manipulate JavaScript's Date object?
- How to subtract date from today's date in JavaScript?
- How to convert a date object to string with format hh:mm:ss in JavaScript?
- How to extract date from string in MySQL?
- What is date object in JavaScript?
- Explain the Date() object in JavaScript?
Advertisements