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


Code AloneRank #488 · 5.1K reputationPosted Sep 28, 2018, 7:52 AM EDT
Rafnas T PRank #280 · 8.8K reputationPosted Sep 28, 2018, 3:33 AM EDT
Ranjit PowarRank #553 · 4.4K reputationPosted Sep 28, 2018, 3:39 AM EDT
Asad AliRank #1,139 · 1.6K reputationPosted Sep 28, 2018, 4:39 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Sep 28, 2018, 6:29 AM EDT
Rajan MishraRank #1,233 · 1.4K reputationPosted Sep 28, 2018, 3:12 AM EDT