Search This Blog

Monday, March 27, 2017

Find different between start date and current date in Local Storage using Javascript

Find different between start date and current date in Local Storage using Javascript 



if (localStorage.getItem('bookname_1') == null) {
  var coeff = 1000 * 60 * 5;
var date = new Date();  //or use any other date
var rounded = new Date(Math.round(date.getTime() / coeff) * coeff)
console.log(rounded)
localStorage.setItem('bookname_1' , rounded);

}else{
var regDate=localStorage.getItem('bookname_1')
regDate=new Date(regDate)
   var now = new Date();
var one_day=1000*60*60*24;
var diffDays = Math.round(Math.abs((now.getTime() - regDate.getTime())/(one_day)));
alert(diffDays)
if(diffDays>=2){// change days here
document.getElementById('black').style.display = 'block';
}
}

1 comment:

  1. igmGuru: We are one of the finest online training Company you can ever come upon solely focused and dedicated to your career development. We have partnered with several well-known companies and prestigious institutions and individuals to train the next generations in IT technologies. Our aim objective is to foster the best growth and upgrade your career objectives with proper knowledge and skills. Passionate training of information technology has always been our motto..All desire to achieve their dream jobs and position but a few succeed to reach their goal. Our vision is to help you to achieve your aim.

    ReplyDelete