KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have this function... private string dateConvert(string datDate) { System.Globalization.CultureInfo cultEnGb = new System.Globalization.CultureInfo("en-GB"); System.Globalization.CultureInfo cultEnUs = new System.Globalization.CultureInfo("en-US"); DateTime dtGb = Convert.ToDateTime(datDate, cultEnGb.DateTimeFormat); datDate = dtGb.ToString(cultEnUs.DateTimeFormat.ShortDatePattern); return datDate; } But I want it with the leading zero still on lower digits (1-9) so the date is 11-09-2009 (mm-dd-yyyy)... Now If I wasn't converting it id use string.Format("{0:d}", dateVar) how do I do this in the conversion? ***** Solution ***** Used a slightly modified version of the answer below (i.e. one that would render). Convert.ToDateTime(datDate).ToString("MM-dd-yyyy");
Tags (comma-separated)
Save Edits
Cancel