I am trying to use string formatting in an object DateTimein C # to get the day of the month without leading zeros.
After some searching, I found some documentation for DateTime formats that shows that I would have to call:
dateTime.ToString("d");
to get the value that I need, but when I tried it, instead of getting numbers like this 28, the yield was: 3/28/2013.
After a bit more searching, I found documentation for standard date and time formats .
Both sets of formats use the format "d", but the results show that the standard string format takes precedence over the custom string format.
Can I specify which formatting is desired?
To coordinate the code, I would prefer to write:
a = dateTime.ToString(...some format...);
b = dateTime.ToString(...some format...);
but not
a = dateTime.ToString(...some format...);
b = dateTime.Day.ToString();
source
share