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
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
This should do the trick:
@Jon Skeet good answer.
For previous Day:
Thanks!!
Now in oneliner flavor - in case you need to pass it as parameter into some mechanism.
In this specific case:
Objective C Version:
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":