// These functions work on local time.
// For UTC, use getUTCDate, setUTCDate,
// getUTCMonth, getUTCFullYear instead.
// Add numDays to date d returning
// a new date object.
function addDays(d, numDays) {
var nd = new Date(d);
nd.setDate(nd.getDate() + numDays);
return nd;
}
// convert date object d to dd/mm/yyyy format.
function ddmmyyyy (d) {
return d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getFullYear();
}
// Put it all together:
var s;
s = ddmmyyyy(addDays(new Date, 7));
// s contains a date 7 days hence in dd/mm/yyyy format.
// END SNIPPET
If you like, you can test the above SNIPPET in my
JavaScript Calculator page located here:
http://www.dst-corp.com/james/javascriptcalc.html
Simply copy and paste everything from BEGIN SNIPPET to
END SNIPPET into the TEXTAREA of the JavaScript Calculator.
NOTE TO MODERATOR: The above is NOT a phishing lure.
I invite you to open the page source and see for yourself.
I use it to test my JavaScript receipts all the time.
James Larson
In God We Trust...
On Wednesday, September 5, 2012 9:39:29 AM UTC-4, Ali Ahmed wrote:
Hi i want to add 7 days in date and date should be show in dd/mm/yyyy format...--
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.