Thursday, 11 March 2010

DateTime Manipulation

I was looking for a resource which would explain all the possible options for formatting strings. I cam across http://www.blackwasp.co.uk/CSharpDateManipulation.aspx


DateTime theDate = DateTime.Parse("3 Jan 2007 21:25:30");
string result;

result = theDate.ToString("d-MM-yy"); // result = "3-01-07"
result = theDate.ToString("HH:mm"); // result = "21:25"
result = theDate.ToString("h:mm tt"); // result = "9:25 PM"


It's not an exhaustive list, but it solved my problem.

No comments:

Post a Comment