
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 6710 Articles for Javascript

1K+ Views
You can use PHP array in JavaScript. It works for a single as well as the multidimensional array. Use the json_encode() method to achieve this.The following is the Multi-dimensional PHP array.$myArr= array( array('Amit', 'amit@example.com'), array('Rahul, 'rahul@example.com'), );Converting PHP multidimensional array into JavaScript. var arr = ; Now, let’s finally learn how to access it to output the email.document.write(arr[1][1]);

16K+ Views
In this tutorial, we will learn to convert JavaScript seconds to minutes and seconds. The problem is that we have given the total number of seconds, and we need to represent it in the minutes and second format. We can perform some basic Mathematics operations and solve our problems. Here, we have two different ways to convert the seconds to minutes and seconds. Using the Math.floor() Method In this approach, we will use the Math.floor() method. We will divide the total number of seconds by 60 to convert it into the minutes and apply the Math.floor() method to round down ... Read More

3K+ Views
You can use PHP array in JavaScript. It works for the single as well as the multidimensional array. Use the json_encode() method to achieve this.Let’s say Our PHP array is −$myArr = array('Amit', 'amit@example.com');Converting PHP array into JavaScript. var arr = ; Now, let’s finally learn how to access it to output the email −document.write(arr[1]);

35K+ Views
In this tutorial, we will look at how to get the first and last date of the current month using JavaScript. In our daily lives, we frequently deal with dates, and we typically are aware of the day—or, at the very least, the month—we are in. To assist users in determining when something has occurred or will occur concerning their current situation, we display the name of a day or a month. This serves as a wonderful chronology. Following are the approaches to get the first and last date of the month using JavaScript − Using a Date Object ... Read More

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

686 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