I've been programming in PHP for quite some time and now I'm trying to learn a new language. I'm creating a webpage and I want to display the current month automatically. In asp.net is the a way to do that? If there's a way can you guys help me?
Asked
Active
Viewed 580 times
-2
-
1Possible duplicate of [C# DateTime to "YYYYMMDDHHMMSS" format](http://stackoverflow.com/questions/3025361/c-sharp-datetime-to-yyyymmddhhmmss-format) – VDWWD May 09 '17 at 06:51
3 Answers
1
DateTime.Now.ToString("MMMM")
should do the job.
Here you have more info about date formats in .NET https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.80).aspx

hardkoded
- 18,915
- 3
- 52
- 64
-
Thanks :) just one more question how can I show the previous month? I mean, I'm creating a newsletter and it shows the articles of the previous month – user2985255 May 08 '17 at 22:13
-
0
If the date is 05/08/2017 and I need to get 04/08/2017 I use something like...
DateTime d = DateTime.Now;
d = d.AddMonths(-1);
this is get the date and subtract a month.

PhatLee
- 37
- 9
-1
Somehow someone -1d my question. The link that was provided only show how to display the date not how to subtract a month which is quite different!!!!

user2985255
- 99
- 1
- 1
- 8