Translate

Friday, 16 June 2017

c# : date name from any date we input

 DateTime myDate = DateTime.Now;
  Response.Write(myDate.DayOfWeek.ToString());// result:Friday


  DateTime myDate = DateTime.Now.AddDays(-65);
  Response.Write(myDate.DayOfWeek.ToString());// result:Wednesday


 DateTime myDate = DateTime.Parse("28/04/1990");// dd/MM/yyyy
 Response.Write(myDate.DayOfWeek.ToString());// result Saturday        

        DateTime myDate = DateTime.Parse("23/11/1989");// dd/MM/yyyy
        Response.Write(myDate.DayOfWeek.ToString());// result Thursday


Console.WriteLine(System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.GetDayName(DateTime.Parse("15/06/2017").DayOfWeek));

No comments:

Post a Comment