add days to Date

Posted on 2013-09-06
Medium Priority
Last Modified: 2013-09-06
Hi All,

Has anybody ever used moment before? http://momentjs.com/

It seems like an easy way to manipulate dates.
I am trying to add days to a date I get from a sharePoint list but it's not working like I expect.
i think my syntax is wrong and I can't find anything on their site about how to do this.

function getCumuVal(dte)
	var nextDate = moment().add('days', 6).calendar(dte);
	alert("nxDte: "+nextDate);

Open in new window

The first alert shows the date being passed in but then the 2nd alert shows this..
"nxDte: Thursday at 11:17 AM".
It shows that for all the dates.

When I tried it this way
var nextDate = moment(dte).add('days', 6);

Open in new window

My alert produced the folllwoing: "1349841600000" but the values were different for each date

Any ideas or how I can add 6 days to any date?

Question by:Isaac
LVL 83

Accepted Solution

leakim971 earned 2000 total points
ID: 39470831
try this :
function getCumuVal(dte)
	var nextDate = moment(dte).add('days', 6).calendar();
	alert("nxDte: "+nextDate);

Open in new window


Author Comment

ID: 39470854


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
AngularJS web development a very simple procedure. So, to put it, in short, AngularJS’ stand out features are – Two-way data binding, MVC structure, directives, templates, dependency injections and testing.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Watch the video of Kernel Migrator for SharePoint, which demonstrate the process easily of migration from SharePoint to SharePoint, OneDrive for Business & Google Drive servers, Public Folder to SharePoint, File Server to SharePoint. The tool has va…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question