Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Get Timestamp in JavaScript</title> </head> <body> <script> // Creating a timestamp var timestamp = Date.now(); document.write(timestamp + "<hr>"); // Converting it back to human-readable date and time var d = new Date(timestamp); document.write(d); </script> </body> </html>