Javascript Articles

Page 296 of 534

How to add 30 minutes to a JavaScript Date object?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 15-Mar-2026 12K+ Views

In JavaScript, there are multiple ways to add 30 minutes to a Date object. This tutorial covers two effective methods: using the setMinutes() method and using the getTime() method. Using the setMinutes() Method The setMinutes() method sets the minutes for a date object and automatically handles overflow to the next hour or day. Syntax Date.setMinutes(min, sec, ms); Parameters min − An integer between 0 and 59, representing the minutes. sec − An integer between 0 and 59, representing the seconds. Optional. ms ...

Read More

Convert text to uppercase with CSS

Prabhas
Prabhas
Updated on 15-Mar-2026 2K+ Views

To convert text to uppercase with CSS, use the text-transform property with the value uppercase. This property transforms the visual appearance of text without modifying the actual content. Syntax text-transform: uppercase; Example Here's how to convert text to uppercase using CSS: .uppercase-text { text-transform: uppercase; } ...

Read More

How to clone a Date object in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 3K+ Views

In this tutorial, we will learn to clone a Date object in JavaScript. We can create a new object of the Date class that contains the date and time according to the user's requirement. Sometimes, it needs to copy the date, which means cloning it. In such cases, users can use the different approaches given below. Also, we will learn to set the new time and date in the cloned date in this tutorial. Using the Date.getTime() Method Users can simply create the new object of the Date class and get the total number of milliseconds from ...

Read More

How can I get time and date since epoch in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 5K+ Views

In this tutorial, we will learn to get the date and time since epoch in JavaScript. Sometimes, programmers need to find the total number of milliseconds, seconds, days, or other time units from 1 January 1970 since the UNIX epoch started. The Unix epoch is the starting point (January 1, 1970, 00:00:00 UTC) used by most computer systems to measure time. JavaScript provides several methods to calculate time elapsed since this date. Using the Date() Constructor In this approach, we will learn to get the current date from the UNIX epoch that started on 1 January 1970. ...

Read More

How to convert epoch Date to meaningful JavaScript date?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 20K+ Views

In this tutorial, we will learn to convert the epoch Date to a meaningful JavaScript date. The epoch date is a representation of the date in milliseconds, and it is a total number of milliseconds since 1st January 1970 since the UNIX epochs started. Users can convert the total number of milliseconds into the meaningful date string using various approaches explained below. Using the new Date() Object In this approach, we will create the object of the Date class. The constructor of the Date() class takes the total number of milliseconds since the epoch started and converts ...

Read More

How to compare only date part without comparing time in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 7K+ Views

While developing applications, you often need to compare only the date parts of two Date objects, ignoring the time components. For example, in a subscription system, you might want to check if a user's payment was made on or before the subscription deadline, regardless of what time the payment was processed. In this tutorial, we will learn to compare only the date part without comparing the time in JavaScript. Using the setHours() Method The most straightforward approach is to set the time components (hours, minutes, seconds, milliseconds) to zero for both date objects. This ensures that when ...

Read More

How to compare two JavaScript Date Objects?

Ramu Prasad
Ramu Prasad
Updated on 15-Mar-2026 421 Views

JavaScript Date objects can be compared directly using comparison operators (>, =, date2) { document.write("Current date is more recent."); } else { document.write("Custom date is more recent."); } Current date: Mon May 28 2018 09:48:49 GMT+0530 (India Standard Time) Custom date: Thu Dec 10 2015 20:15:10 GMT+0530 (India Standard Time) Current date is more recent. Comparing for ...

Read More

Usage of text-align property in CSS

V Jyothi
V Jyothi
Updated on 15-Mar-2026 118 Views

The text-align property in CSS controls the horizontal alignment of text content within its container. It accepts several values to position text left, right, center, or justify it across the available width. Syntax text-align: left | right | center | justify | start | end; Property Values Value Description left Aligns text to the left (default) right Aligns text to the right center Centers text horizontally justify Stretches text to fill the full width Example Here's how to use different ...

Read More

How to convert a date object to string with format hh:mm:ss in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 10K+ Views

We will learn to convert the date object to a string with the format hh:mm:ss in JavaScript. Working with dates and times is common in web development, and formatting them according to specific requirements is an essential skill. The default date object returns a complete date string, which might contain more information than needed. Here, we will explore different approaches to extract and format just the time portion in hh:mm:ss format. Using toTimeString() Method The toTimeString() method returns the time portion of a Date object as a human-readable string. We can then extract the first 8 characters ...

Read More

How do I subtract minutes from a date in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 6K+ Views

In this tutorial, we will learn to subtract minutes from a date in JavaScript. Working with dates is a common requirement in web development, and JavaScript provides built-in Date class methods to handle date manipulations effectively. We'll explore three approaches: using native JavaScript methods getMinutes() and setMinutes(), working with milliseconds, and using the Moment.js library for more convenient date operations. Using the getMinutes() and setMinutes() Methods This approach uses the Date object's built-in methods to extract current minutes, subtract the desired amount, and update the date object. Syntax let date = new Date(set_date); let ...

Read More
Showing 2951–2960 of 5,340 articles
« Prev 1 294 295 296 297 298 534 Next »
Advertisements