By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,002 Members | 2,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,002 IT Pros & Developers. It's quick & easy.

how to find previous date from any dates

P: 94
Hi,
I need to find the previous date from a given date in java script. Is there any code for it.Can anyone tell me.Thanks in advance
Jan 12 '08 #1
Share this Question
Share on Google+
2 Replies


acoder
Expert Mod 15k+
P: 16,027
What do you mean by previous date? The day before the given date?

You can just subtract the number of days from the current date, e.g. if you have a date object called date,
Expand|Select|Wrap|Line Numbers
  1. date.setDate(date.getDate() - previous); // where previous is the number of days to subtract
Jan 12 '08 #2

P: 2
@acoder, thanks for ur solution, it helped me a lot
Mar 15 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.