C# ToString("MM/dd/yy") remove leading 0's

Evan Layman picture Evan Layman · Jul 25, 2011 · Viewed 17.6k times · Source

Possible Duplicate:
Format .NET DateTime “Day” with no leading zero

Is there a way to remove the leading zeros in the date format

For example, X.ToString("MM/dd/yy") returns 07/02/11 but I'd like it to instead return 7/2/11.

Is this possible?

Thanks

Answer

reggie picture reggie · Jul 25, 2011

X.ToString("M/d/yy") is what you need