InterviewSolution
Saved Bookmarks
| 1. |
Is it possible to create a custom alert box in JavaScript? |
|
Answer» The getMinutes() method is provided by JavaScript to get the current minutes in JavaScript. The minutes are according to LOCAL time. We will add minutes to it using the setMinutes() method. Create a DATE object: VAR date = new Date();Now get the current date and time: // current date and time document.write("Current Date and Time = "+date);Now, under setMinutes(), get the current minutes using getMinutes() and add the minutes as shown below. We added 10 minutes here: date.setMinutes(date.getMinutes() + 10 );The following is an example to add 15 minutes to a date in JavaScript: <html> <head> <TITLE>JavaScript setMinutes() Method</title> </head> <body> <script> var date = new Date(); // current date and time document.write("Current Date and Time = "+date); date.setMinutes(date.getMinutes() + 15 ); document.write("<br>New Date = "+date); </script> </body> </html>The output: Current Date and Time = Sat Dec 15 2018 20:11:14 GMT+0530 (India Standard Time) New Date = Sat Dec 15 2018 20:26:14 GMT+0530 (India Standard Time) |
|