Saturday, 13 May 2017

Add number of days to a Date in javascript 0


Add number of days to a Date in javascript / Add number of days to current date in javascript


To add number of days to a Date, we need to convert our date string to a date object. Here we are going to use javascript inheritance property (prototype) to do that.

Actual function :

Date.prototype.addDays = function(days){
     return new Date(this.getTime()+days*24*60*60*1000);
In this function we are going to convert days to milliseconds using days*24*60*60*1000 and adding to our date object.

Code usage :

var ourDate = new Date('2014','11','12');
/*for current date just use below line of code instead of above line
var ourDate = new Date();
//Now we are going to add 100 days to our date object.
var futureDate = ourDate.addDays(100);

How to set root password for mysql server 0

Simply follow these two steps.

open command prompt or console. change control to in where mysql.exe is located. Mostly it will located inside mysql's bin directory.

You have to execute the following command

mysqladmin -u root password 'your_root_password'

replace 'your_root_password' with your desired password.

or simply you can run this sql command in your query window.

SET PASSWORD FOR root@localhost = PASSWORD('your_root_password');