

- 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 clone a Date object in JavaScript?
To clone a Date object in JavaScript, you can try to run the following code. Here, we’ve cloned the current date:
Example
<html> <head> <title>JavaScript Clone Date</title> </head> <body> <script> var current_date, clonedDate; current_date = new Date(); document.write(current_date); var clonedDate = new Date(current_date.getTime()); document.write("<br>"+clonedDate); </script> </body> </html>
Output
Mon May 28 2018 09:27:54 GMT+0530 (India Standard Time) Mon May 28 2018 09:27:54 GMT+0530 (India Standard Time)
- Related Questions & Answers
- How to clone an object in JavaScript?
- How to clone an object using spread operator in JavaScript?
- How to clone a js object except for one key in javascript?
- How to create a Date object in JavaScript?
- How to create JavaScript Date object from date string?
- How to convert a JavaScript date object to a string?
- How to convert a string in to date object in JavaScript?
- How to add 30 minutes to a JavaScript Date object?
- How to add 2 hours to a JavaScript Date object?
- How to add 10 seconds to a JavaScript date object?
- How to manipulate JavaScript's Date object?
- How to convert a Python date string to a date object?
- How to convert a JS Date to a Python date object?
- How to convert a Date object to LocalDate object in java?
- What is date object in JavaScript?
Advertisements