Geeks With Blogs


Add to Google

Tim Hibbard CEO for EnGraph software June 2008 Entries
C# DateTime extension method
Currently DateTime.ToShortDateString will not include any "0" prefixes. I think this makes any vertical lists of dates look funky: Here is a very simple extension method that will append any needed leading "0" to the date: namespace ParaPlan.Extensions{ public static class DateHelper { public static string ToShortDateEqualLengthStrin... DateTime dt) { var rv = new StringBuilder(); if (dt.Month.ToString().Length ==1) { rv.Append("0"); } rv.Append(dt.Month.ToString... rv.Append("/"); if (dt.Day.ToString().Length ......

Posted On Thursday, June 26, 2008 3:43 PM

Copyright © Tim Hibbard | Powered by: