Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Date get today date minus 1 week [duplicate]

Am using the following for my date in javascript

I would like to get a date plus 1 more day

so i have

new Date(2018, 1, 12, 10, 30)

THe above creates a date on 12th

Now i would like to get a date 1 week from todat

How do i go about it using Date

like image 809
Geoff Avatar asked Jul 13 '26 17:07

Geoff


2 Answers

A very simple (but ugly) way to do it.

new Date(Date.now() + 604800000);
like image 99
P Roitto Avatar answered Jul 15 '26 05:07

P Roitto


I guess you could just go:

var date = new Date(2018, 1, 12, 10, 30);
date.setDate(date.getDate() + 7);
like image 43
Marty Avatar answered Jul 15 '26 06:07

Marty