How can I add 1 day to current date?
To add one day to a date object:
var date = new Date();
// add a day
date.setDate(date.getDate() + 1);
add the specified number of days to current date in c#
string s = DateTime.Now.AddDays(2).ToString();
UPDATE
In answer to your comment
string s = DateTime.Now.AddDays(2).ToShortDateString();
Add 30 days to a Current date - JS
var date = new Date(); // Now
date.setDate(date.getDate() + 30); // Set now + 30 days as the new date
console.log(date);
momentJS date string add 5 days
UPDATED: January 19, 2016
As of moment 2.8.4 - use .add(5, 'd')
(or .add(5, 'days')
) instead of .add('d', 5)
var new_date = moment(startdate, "DD-MM-YYYY").add(5, 'days');
Thanks @Bala for the information.
UPDATED: March 21, 2014
This is what you'd have to do to get that format.
Here's an updated fiddle
startdate = "20.03.2014";
var new_date = moment(startdate, "DD-MM-YYYY").add('days', 5);
var day = new_date.format('DD');
var month = new_date.format('MM');
var year = new_date.format('YYYY');
alert(day + '.' + month + '.' + year);
ORIGINAL: March 20, 2014
You're not telling it how/what unit to add. Use -
var new_date = moment(startdate, "DD-MM-YYYY").add('days', 5);
Adding days to a date in Python
The previous answers are correct but it's generally a better practice to do:
import datetime
Then you'll have, using datetime.timedelta
:
date_1 = datetime.datetime.strptime(start_date, "%m/%d/%y")
end_date = date_1 + datetime.timedelta(days=10)
How to add number of days to exact date format
Use this code:
$today = date("m/d/y");
echo date('m/d/y', strtotime($today. ' +10 day'));
Out put will be 11/28/13
as you desiring.
Related Topics
Can't Perform a React State Update on an Unmounted Component
JavaScript: Remove Event Listener
Null-Safe Property Access (And Conditional Assignment) in Es6/2015
How to Get Just Numeric Part of CSS Property with Jquery
How to Determine If ::Before Is Applied to an Element
Programmatically Focus on Next Input Field in Mobile Safari
Change the Selected Value of a Drop-Down List with Jquery
Rotate the Elements in an Array in JavaScript
How Does This JavaScript/Jquery Syntax Work: (Function( Window, Undefined ) { })(Window)
JavaScript: Difference Between .Foreach() and .Map()
Evaluating a String as a Mathematical Expression in JavaScript
JavaScript and Operator Within Assignment
Html5 Video - Percentage Loaded
Polymer Share Styles Across Elements
Mobile Safari on iOS Crashes on Big Pages
Error: No Firebase App '[Default]' Has Been Created - Call Firebase App.Initializeapp()