To get the date 5 days from now in JavaScript, you can create a new Date
object and add 5 days to it using the setDate()
method. Here's an example:
index.tsx79 chars3 lines
In this example, now
is the current date and time. The setDate()
method is used to add 5 days to the current date. The resulting date is stored in the nextWeek
variable.
You can then format the date as a string using the toLocaleString()
method:
index.tsx40 chars2 lines
This will output the date and time as a string in your local time zone. For example: "6/17/2021, 6:23:15 PM"
gistlibby LogSnag