How to convert UTC date time into local date time using JavaScript ?
Given an UTC date and the task is to convert UTC date time into local date-time using JavaScript toLocaleString() function....
read more
How to get seconds since epoch in JavaScript?
Given a date, we have to find the number of seconds since the epoch (i.e. 1 January 1970, 00:00:00 UTC ). The getTime() method in the JavaScript returns the number of milliseconds since January 1, 1970, or epoch. If we divide these milliseconds by 1000 and then integer part will give us the number of seconds since epoch....
read more
How do you display JavaScript datetime in 12 hour AM/PM format ?
JavaScript uses the 24-hour format as the default for DateTime. However, daytime in JavaScript can be displayed in 12-hour AM/PM format using several approaches....
read more
How to get the first and last date of current month using JavaScript ?
Given a month and the task is to determine the first and last day of that month in proper format using JavaScript....
read more
How to remove time from date using JavaScript ?
Given a Date Object and the task is to remove the time portion from the object using JavaScript....
read more
How to convert seconds to time string format hh:mm:ss using JavaScript ?
Given a time in seconds, the task is to convert the time into a string format hh:mm:ss. There are two approaches to solving this problem...
read more
JavaScript Date getTime() Method
JavaScript Date getTime() Method is used to return the number of milliseconds since 1 January 1970. When a new Date object is created it stores the date and time data when it is created. The getTime() always uses UTC for time representation....
read more
Sort an Object Array by Date in JavaScript
To sort an Object Array by Date in JavaScript, we have different approaches. We are going to learn how to sort an Object Array by Date in JavaScript....
read more
How to check if one date is between two dates in JavaScript ?
The task is to determine if the given date is in between the given 2 dates or not? Here are a few of the most used techniques discussed with the help of JavaScript. In the first approach, we will use .split() method and the new Date() constructor. And in the second approach we will use the .getTime() method with the new Date() constructor. Approach 1: Use .split() method to split the date on “/” to get the day, month and year in an array. The we have to construct the date from the array obtained in previous step for that we will use the new Date() constructor . Because this method returns the number of seconds from 1 Jan 1970, So it becomes easy to compare the dates....
read more
JavaScript Date toString() Method
JavaScript date.toString() method is used to convert the given date object’s contents into a string. The date object is created using the date() constructor....
read more
How to get Month and Date of JavaScript in two digit format ?
To get the Month and Date of JavaScript in two-digit format, we have multiple approaches. In this article, we are going to learn how to get the Month and Date of JavaScript in a two-digit format....
read more
JavaScript | Date Objects
The Date object is an inbuilt datatype of JavaScript language. It is used to work with dates and times. The Date object is created by using new keyword, i.e. new Date(). The Date object can be used date and time in terms of millisecond precision within 100 million days before or after 1/1/1970. But using another methods we can only get and set the year, month, day, hour, minute, second, and millisecond fields using local or UTC or GMT time. So we can represent date and time till the year 275755 using Date object. There are four different way to declare a date, the basic things is that the date objects are created by the new Date() operator. Syntax:...
read more