Reputation: 717
I’m doing the code below in my view but I just get the month and number of the month in regards to 12 months of the year like this:
May 5 instead of May 14.
Here’s the code I have in my view:
@{
DateTime now = DateTime.Now;
String date = now.ToString("MMM");
}
What I want is the month and the date of the month. What am I doing wrong here?
Upvotes: 0
Views: 59
Reputation: 2355
Try
@{
DateTime now = DateTime.Now;
int month = now.Month;
string monthName=now.ToString("m").Split(' ')[1];
int day=now.Day;
}
Upvotes: 1