4
How to take the current date in Javascript, and create another date, only 24 hours before?
To catch the current time just do:
var data = new Date();
to pick up 24 hours before, as it does?
4
How to take the current date in Javascript, and create another date, only 24 hours before?
To catch the current time just do:
var data = new Date();
to pick up 24 hours before, as it does?
5
You can use the .setDate
and spend a day less than the current date, so it will change the internal date of that variable to what you want:
var data = new Date();
data.setDate(data.getDate() - 1);
console.log(data);
1
Decrease the current date by the amount of milliseconds in 24h.
var date = (new Date () - ((24*60*60)*1000));
console.log(new Date(date));
0
The getDate() function of the Date object captures the day
data = new Date();//cria o objeto
dia = data.getDate();//recupera o dia atual
console.log(dia)
so it is positive to manipulate the variable day as you wish.
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
Exactly that.
– wen-dell