Aniket Narvankar

Aniket Narvankar

  • 818
  • 1.7k
  • 310.2k

C Sahrp Date Time Functions

Sep 28 2018 7:10 AM
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 

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (6)