Remove leading zero form month C#
c#, datetime
Solution
It's interpreting `M` as a standard date and time format for "month day pattern".
To interpret a single character pattern as a custom date and time pattern, just prefix it with `%`:
string test = billrunDate.ToString("%M");
Problem
I'm having trouble to remove the leading zero from a date I found this on the miscrosoft website. ``` DateTime date1 = new DateTime(2008, 8, 18); Console.WriteLine(date1.ToString("(M) MMM, MMMM", CultureInfo.CreateSpecificCulture("en-US"))); // Displays (8) Aug, August ``` Totally doesn't work here. This is my code: ``` string date = '2013-04-01' DateTime billrunDate = Convert.ToDateTime(date); string test = billrunDate.ToString("M"); ``` Test is now `01 April` I just need it to be `4` in a string or int idc Thanks! Edit if I do: ``` billrunDate.ToString("(M)"); ``` I get `(4)`, but I dont need `()` EDIT 2: Well this works ``` string test = billrunDate.ToString(" M "); string testTwo = test.Trim(); ``` Very very ugly