Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Web Development Articles
Page 350 of 801
How do I subtract minutes from a date in JavaScript?
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 MoreHow to get time difference between two timestamps in seconds?
To get the time difference between two timestamps in seconds, you can subtract one Date object from another and divide by 1000. JavaScript Date objects return milliseconds when subtracted, so dividing by 1000 converts to seconds. Basic Time Difference in Seconds The simplest approach is to subtract two Date objects and convert milliseconds to seconds: Time Difference in Seconds var date1 = new Date("Jan 1, 2018 11:10:05"); ...
Read MoreStrikethrough text with CSS
Use the text-decoration property to create strikethrough text with CSS. The line-through value draws a horizontal line through the middle of the text. Syntax text-decoration: line-through; Basic Example This text will be striked through. Using CSS Classes For better organization, use CSS classes instead of inline styles: ...
Read MoreHow to get current date/time in seconds in JavaScript?
To get the current time in seconds in JavaScript, you can extract hours, minutes, and seconds from a Date object and convert them to total seconds using the formula: (hours * 3600) + (minutes * 60) + seconds Method 1: Converting Current Time to Seconds This approach gets individual time components and calculates total seconds since midnight: JavaScript Get Seconds ...
Read MoreConvert text to uppercase with CSS
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 MoreHow to get the number of seconds between two Dates in JavaScript?
In JavaScript, calculating the difference between two dates in seconds is a common requirement for timers, age calculators, and duration displays. JavaScript Date objects provide millisecond precision, which we can easily convert to seconds. Using the getTime() Method The getTime() method returns the number of milliseconds since January 1, 1970 UTC. By subtracting two timestamps and dividing by 1000, we get the difference in seconds. Syntax let date1 = new Date("Aug 12, 2022 19:45:25"); let date2 = new Date("Aug 14, 2022 19:45:25"); let seconds = Math.abs(date1.getTime() - date2.getTime()) / 1000; Example ...
Read MoreHow to convert a MySQL date to JavaScript date?
In this tutorial, we will learn to convert the MySQL date to JavaScript date. The MySQL date is not different from the regular date, but its format or syntax is different, which we need to convert into the format of a normal date. The general syntax of the MySQL date is YYYY-MM-DD HH:mm:ss. So, we need to convert the given MySQL date string syntax to normal date syntax. We will have two approaches to converting the MySQL date to the JavaScript date. Using the replace() Method Using the split() Method ...
Read MoreHow to get the difference between two arrays in JavaScript?
To get the difference between two arrays in JavaScript, you can find elements that exist in one array but not in both. This is commonly called the symmetric difference. There are several approaches to achieve this. Using filter() and includes() (Recommended) Array Difference function arrayDifference(arr1, arr2) { // Elements in ...
Read MoreUsage of text-align property in CSS
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 MoreHow to get the value of PI in JavaScript?
In this tutorial, we will learn how to get the value of PI in JavaScript. The PI is a mathematical constant that is widely used in different sections of mathematics. It is defined by the ratio of the circumference of a circle to its diameter, which is approximately 3.14159. It is represented by the symbol '𝜋', which is a Greek letter. The value of PI is an irrational number, which means the value of the PI can't be expressed as a fraction, and the digits that came after the decimal are non-terminating and non-repeating. The value ...
Read More