Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

How To Add Days To JavaScript Date With date-fns

node v18.11.0
version: 2.0.0
endpointsharetweet
// import isn't supported in Node v18.11.0 otherwise it would be // import { addDays } from 'date-fns' const dateFns = require( "date-fns"); const {addDays} = dateFns; // 4th of July 2023 const date = new Date(2023, 6, 4); console.dir(date); console.log('Add 3 days: ', addDays(date, 3)); console.log('Add 7 days: ', addDays(date, 7)); console.log('Add 31 days: ', addDays(date, 31));
Loading…

no comments

    sign in to comment