Thursday 5 February 2015

how to get Year, Month Day in C# code

DateTime dtDate= new DateTime(1999, 1, 13, 3, 57, 32, 11);
   // Year gets 1999. 
   int year = dtDate.Year;
   
   // Month gets 1 (January). 
   int month = dtDate.Month;
   
   // Day gets 13. 
   int day = dtDate.Day;
   
   // Hour gets 3. 
   int hour = moment.Hour;
   
   // Minute gets 57. 
   int minute = dtDate.Minute;
   
   // Second gets 32. 
   int second = dtDate.Second;
   
   // Millisecond gets 11. 
   int millisecond = dtDate.Millisecond;


Get from MSDN

No comments:

Post a Comment