Try something like this:
var d = new Date(); d.setDate(d.getDate()-5);
Note that this modifies the date object and returns the time value of the updated date.
var d = new Date(); document.write('Today is: ' + d.toLocaleString()); d.setDate(d.getDate() - 5); document.write('<br>5 days ago was: ' + d.toLocaleString());
Related Posts:
- How to format a JavaScript date
- How to format a JavaScript date
- How do I get the current date in JavaScript?
- Get String in YYYYMMDD format from JS date object?
- Compare two dates with JavaScript
- Compare dates with javascript
- Add days to JavaScript Date
- Parsing a string to a date in JavaScript
- Format JavaScript date as yyyy-mm-dd
- Add days to JavaScript Date
- How to validate date with format “mm/dd/yyyy” in JavaScript?
- How to subtract date/time in JavaScript?
- Getting current date and time in JavaScript
- Shortest way to print current year in a website
- Validate date in dd/mm/yyyy format using JQuery Validate
- How to add 30 minutes to a JavaScript Date object?
- How do you convert a JavaScript date to UTC?
- Convert UTC Epoch to local date
- Convert normal date to unix timestamp
- Check time difference in Javascript
- How to convert date to timestamp?
- How to format a UTC date as a `YYYY-MM-DD hh:mm:ss` string using NodeJS?
- Moment Js UTC to Local Time
- Get hours difference between two dates in Moment Js
- Javascript: getFullyear() is not a function
- React – uncaught TypeError: Cannot read property ‘setState’ of undefined
- Cannot read property ‘push’ of undefined when combining arrays
- How can I remove a specific item from an array?
- Add swipe left/right to web page, but use default swipe up/down
- Check if checkbox is checked with jQuery
- What does “res.render” do, and what does the html file look like?
- How to pause javascript code execution for 2 seconds [duplicate]
- Getting Error “Form submission canceled because the form is not connected”
- How to implement navbar using react
- function updateMap for Google Maps API
- Loop inside React JSX
- Disable/enable an input with jQuery?
- npm – EPERM: operation not permitted on Windows
- ChangeDate – Date Picker Bootstrap
- Is there a sleep function in JavaScript?
- scrollIntoView Scrolls just too far
- Javascript Uncaught TypeError : .split is not a function
- Uncaught TypeError: Cannot read property ‘msie’ of undefined
- How to go from one page to another page using javascript?
- How to update array value javascript?
- DOMException: Failed to load because no supported source was found
- Counting the occurrences / frequency of array elements
- JavaScript: Create and save file
- Adding options to a
- How to use scientific notation in js?
- String.Format not work in TypeScript
- jQuery Ajax POST example with PHP
- How to validate a credit card number
- TypeError: res.status is not a function
- What is define([ , function ]) in JavaScript?
- Setting and getting localStorage with jQuery
- setInterval with loop time
- JavaScript by reference vs. by value
- What does the .subscribe() function do?
- is there something like isset of php in javascript/jQuery?
- jQuery – Dynamically Create Button and Attach Event Handler
- How to disable auto-start of “Node.js: Server-side JavaScript” when using Adobe Dreamweaver?
- Regular expression to validate US phone numbers?
- How should I initialize jQuery?
- How to reload page every 5 seconds?
- How do I handle newlines in JSON?
- Update style of a component onScroll in React.js
- Fire oninput event with jQuery
- WordPress Bootstrap Handburger Menu Wont Open
- Reset Undo on the tinymce editor
- Detecting WordPress Customizer Panel
- How to disable hoverIntent in WordPress 3.3 admin
- Customizer – instantiating settings and controls via javascript
- How do I enqueue(or delay loading of) tags in individual page posts?
- JavaScript in page doesn’t open new window [closed]
- Animations are not being triggered on Scroll
- Preserve Javascript Through Customizer Preview Navigation
- How to use div -ids in url to jump to specific post…Is trailing slash the culprit?
- can a buttongroup have a label?
- Preloader for a WordPress Site
- Trying to integrate Zoho Campaign Form [closed]
- What’s the most efficient way to include this javascript in only a single post?
- InnerBlocks restricting does not work on nested blocks
- How to add customizer control via javascript ( wp.customizer.control.add )
- How to execute Javascript on a WordPress page?
- Removing auto versioning of JS and loading to header
- Gutenberg select excerpt, use generated excerpt or use more block excerpt
- Unable To Call Javascript With Enqueue
- How to integrate a JS fiddle?
- Hovercards and other hover over image functions don’t work anymore!
- Load JavaScript on specific page with @wordpress compiler
- How WP does Mortgage affordability calculation
- java console error about touch navigation
- Update block once an API request returns with a value
- How to improve WP-Rest atrocious response time?
- How should I identify the inline javascript that is the dependent of a wp_enqueue_script?
- How do I add a class to Customizer preview based on class of Customizer control? (Customizer Javascript API)
- Open image gallery on link click
- WordPress 4.2 mce-views migration guide?
- Loaded JavaScript file not showing [duplicate]