6
Answers

C Sahrp Date Time Functions

I want current system date in c sharp in this format,
28-SEP-2018,so I write the following code
 
string Day = Convert.ToString(DateTime.Now.Day);
string Year = Convert.ToString(DateTime.Now.Year);
string month = DateTime.Now.ToString("MMM").ToUpper();
string date = Day + "-" + month + "-" + Year;
It is giving me date in required format.Is there any other way this could be done in C Sharp? Before this I used this code
string currentDate = DateTime.Now.ToString("dd-MM-yyyy");
but it give me output as 24-08-2018 
Answers (6)