How To Add Hours To A JavaScript Date?

In this article, we are going to learn how you can add hours to a JavaScript date. Before that, let’s see what is a date object. What Is Date? It is an in-built object in Javascript which is use to reference a certain point of time. By default, new Date() creates a Date object with … Read more

Get The Current Month In JavaScript

To get the current month in JavaScript – Create a new date using the Date() constructor. Use the getMonth() + 1 method to get the month (remembering that January is 0). You can even use Moment.js methods to get current month. Let’s first have a look at what all of these methods do. getMonth(): Returns … Read more

Convert Date To Unix Timestamp In JavaScript

To convert date to Unix timestamp in JavaScript – Create a Date object using the Date constructor. Get the timestamp using the getTime() method. Divide the number by 1000 to get the timestamp in seconds. Use Math.floor() to get rid of the decimal places. Here is an example: You can pass a date string to … Read more