问题
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
回答1:
X.ToString("M/d/yy")
is what you need
回答2:
Just remove the extra M
and d
.
回答3:
You can use "M/d/yy"
. See here for more details.
回答4:
You can write X.ToString("M/d/yy")
回答5:
It is X.ToString("M/d/y")
if you want to remove ALL leading zeroes ;)
来源:https://stackoverflow.com/questions/6820605/c-sharp-tostringmm-dd-yy-remove-leading-0s