get a year ago datetime c# code example
Example 1: get time from datetime c#
DateTime dt = DateTime.Parse("6/22/2009 07:00:00 AM");
dt.ToString("HH:mm"); // 07:00 // 24 hour clock // hour is always 2 digits
dt.ToString("hh:mm tt"); // 07:00 AM // 12 hour clock // hour is always 2 digits
dt.ToString("H:mm"); // 7:00 // 24 hour clock
dt.ToString("h:mm tt"); // 7:00 AM // 12 hour clock
Example 2: get day month year from date c#
// can add : or / to seperate dates and time
DateTime.Now.ToString("yyyyMMddhhmmss")