
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10483 Articles for Web Development

1K+ Views
In the given problem statement we will write a function to calculate the days between the given dates with the help of Javascript functionalities. For solving this problem we will use some built in method of Javascript and mathematical operations. Understanding the problem statement In the given problem we have to create a function to compute the number of days as outcome after calling the function by passing two dates. And this task can be done using Date object and basic math. For example if we have two dates like 2023-02-15 and 2023-02-25, so between these dates there are 10 ... Read More

8K+ Views
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 Using the ... Read More

21K+ Views
In this tutorial, we will learn how to get the number of seconds between two dates with JavaScript. There are different methods for checking the number of days, hours, and seconds that are commonly used to provide information related to data. Since you can’t manually change the count of the years and months, we follow some simple tricks to get the number in JavaScript. Using the Date getTime() Method In JavaScript, we use different methods to calculate the days, hours, and seconds. Most popular way to calculate the time is .getTime(). However, you will get the result in milliseconds and ... Read More

687 Views
To convert time in seconds, firstly get the current time. Then, multiply the hours to 3600 and minutes to 60; rest you can see below −(hours*3600) + (min*60) + secExampleYou can try to run the following code to get the current time in seconds −Live Demo JavaScript Get Seconds var dt = new Date(); var sec = dt.getSeconds(); document.write("Seconds: " + sec); var min = dt.getMinutes(); document.write("Minutes: " + min); var hrs = dt.getHours(); document.write("Hours: " + hrs); var total_seconds = (hrs*3600) + (min*60) + sec; document.write("Total seconds: " + total_seconds) ; OutputSeconds: 35 Minutes: 37 Hours: 9 Total seconds: 34655

3K+ Views
To get the time difference between two timestamps, try to run the following code. Here, we are calculating the total number of hours, minutes and seconds between two timestamps −ExampleLive Demo JavaScript Dates var date1, date2; date1 = new Date( "Jan 1, 2018 11:10:05" ); document.write(""+date1); date2 = new Date( "Jan 1, 2018 08:15:10" ); document.write(""+date2); var res ... Read More

37K+ Views
To add months to a date in JavaScript, you can use the Date.setMonth() method. JavaScript date setMonth() method sets the month for a specified date according to local time. This method takes two parameters first is the number of months and the second parameter is the number of days. The counting of the month is start from 0, for example, 0 represents January, 1 represents February ... and so on. Syntax Date.setMonth(monthsValue , [daysValue]); Note − Parameters in the bracket are always optional. Parameter Detail monthsValue − An integer between 0 and 11, representing the months. Although we ... Read More

270 Views
To remove first array element, use the JavaScript shift() method. JavaScript array shift() method removes the first element from an array and returns that element.ExampleYou can try to run the following code to remove first array element and return it −Live Demo JavaScript Array shift Method var element = [30, 45, 70, 90, 110].shift(); document.write("Removed first element is : " + element ); OutputRemoved first element is : 30

5K+ Views
In this tutorial, we will learn to subtract minutes from the date in JavaScript. While developing the applications, programmers need to play with the dates many times. All JavaScript programmers are lucky enough that JavaScript contains the built-in date class with hundreds of different methods.In this tutorial, we will learn to subtract the minutes from the date in vanilla JavaScript using the date object and the Moment JS library.Using the getMinutes() and setMinutes() MethodsIn this approach, we will create a new date object and extract the minutes from that using the getMinutes() method.After that, we will update the minutes by ... Read More

9K+ Views
We will learn to convert the date object to a string with the format hh:mm:ss in JavaScript. It is a rear case that developers don’t use the date and time while developing the application. So, it is also important to learn to manipulate the dates. The default date object returns the date string. Maybe it can be weird as you don’t need to show everything from it. So, users can format the date string according to their requirements. Here, we will see different approaches to format the date string. Format the date using toISOString() method In this approach, we will ... Read More

361 Views
To compare two date objects with JavaScript, create two dates object and get the recent date to compare it with the custom date.ExampleYou can try to run the following code to compare two dates −Live Demo var date1, date2; date1 = new Date(); document.write(date1); date2 = new Date( "Dec 10, 2015 20:15:10" ); document.write(""+date2); if (date1 > date2) { document.write("Date1 is the recent date."); } else { document.write("Date 2 is the recent date."); } OutputMon May 28 2018 09:48:49 GMT+0530 (India Standard Time) Thu Dec 10 2015 20:15:10 GMT+0530 (India Standard Time) Date1 is the recent date