var days = 1;
var newDate = new Date(Date.now() + days * 24*60*60*1000);
document.write('Today: <em>');
document.write(new Date());
document.write('</em><br/> New: <strong>');
document.write(newDate);
I get that I need to use .getMinutes to add extra value for date like one minute.
You have any idea this why not work
if (d > myDate)
d is current time mydate is set +1 minute untill disable button bit is stay enabled true why after d current time is greanter than set myDate plus 1 minute?
Yes is get disabled true for one minute after current date is greater than myDate (when click button + one minute) then able to send again the button disabled false. I got crazy my mind with it
@camperextraordinaire This planned for able send one click event per 60 seconds. I not want the user click more than once just if try send it more then not able to do with disabled true. I think about it is something like a limit for click. Is not able to click like a robot have to wait :).
I refactored your code to make it more readable and do what you intended to do.
$(document).ready(function() {
function disableLikeButton() {
$('#like').prop("disabled", true);
}
var localStorageDateString = localStorage.getItem('test');
var currentDate = new Date();
if (localStorageDateString) {
var localStorageDate = new Date(localStorageDateString);
if (localStorageDate.getTime() > currentDate.getTime()) {
disableLikeButton();
}
}
$('#like').click(function() {
var currentDate = new Date();
currentDate.setMinutes(currentDate.getMinutes() + 1);
localStorage.setItem('test', currentDate);
disableLikeButton();
});
});