Web Development Articles

Page 349 of 801

Align the text of a document with CSS

varma
varma
Updated on 15-Mar-2026 117 Views

The text-align property in CSS is used to align the text content within an element. It accepts several values: left (default), right, center, and justify. Syntax text-align: left | right | center | justify; Values left: Aligns text to the left edge (default) right: Aligns text to the right edge center: Centers the text horizontally justify: Spreads text evenly across the width, aligning both left and right edges Example Here's how to use different text alignment values: ...

Read More

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

Add or subtract space between the words of a sentence with CSS

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 475 Views

The word-spacing property is used to add or subtract space between the words of a sentence. Possible values are normal or a number specifying space. Syntax word-spacing: normal | length | initial | inherit; Parameters Value Description normal Default spacing between words length ...

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 426 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

Underline text with CSS

mkotla
mkotla
Updated on 15-Mar-2026 1K+ Views

Use the text-decoration property to underline text with CSS. This property provides several options for decorating text, with underline being one of the most commonly used values. Syntax text-decoration: underline; Basic Example India Different Underline Styles You can customize the underline appearance using additional properties: ...

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
Showing 3481–3490 of 8,010 articles
« Prev 1 347 348 349 350 351 801 Next »
Advertisements