---
title: "Timestamp in JavaScript"  
description: "Timestamp in JavaScript"  
author: "Anonymous User"  
published: 2021-07-20  
updated: 2021-07-20  
canonical: https://www.mindstick.com/forum/156568/timestamp-in-javascript  
category: "javascript"  
tags: ["javascript", "datetime"]  
reading_time: 1 minute  

---

# Timestamp in JavaScript

How do you get a [timestamp](https://www.mindstick.com/interview/791/what-does-timestamp-on-update-current_timestamp-data-type-do) in [JavaScript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript)? How to change the [format](https://www.mindstick.com/forum/162083/how-to-convert-ost-files-into-pst-format) of the Timestamp?

## Replies

### Reply by Anonymous User

To get current timestamp through javascript you can use date() object through which you can get current time of your machine.

There are several methods in JavaScript that can return specific information from a Date object:

Method Description :

- getFullYear() Get the year as a four digit number (yyyy)
- getMonth() Get the month as a number (0-11)
- getDate() Get the day as a number (1-31)
- getHours() Get the hour (0-23)
- getMinutes() Get the minute (0-59)
- getSeconds() Get the second (0-59)
- getMilliseconds() Get the millisecond (0-999)
- getTime() Get the time (milliseconds since January 1, 1970)
- getDay() Get the weekday as a number (0-6)
- Date.now() Get the time. ECMAScript 5.

Let's understand it with the help of an example :

```
<!DOCTYPE html>
<html>
<body>
    <p id='demo'></p>
    <script>
        var timestamp = new Date();
        document.getElementById('demo').innerHTML = timestamp;
    </script>
</body>
</html>
```

Hope this code will be helpful for you.

Happy Coding!


---

Original Source: https://www.mindstick.com/forum/156568/timestamp-in-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
