How can I get the date of next Tuesday?
In PHP, it’s as simple as strtotime('next tuesday');.
How can I achieve something similar in .NET
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As I’ve mentioned in the comments, there are various things you could mean by “next Tuesday”, but this code gives you “the next Tuesday to occur, or today if it’s already Tuesday”:
If you want to give “a week’s time” if it’s already Tuesday, you can use:
… or you could use the original formula, but from tomorrow:
EDIT: Just to make this nice and versatile:
So to get the value for “today or in the next 6 days”:
To get the value for “the next Tuesday excluding today”: