开发者

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

开发者 https://www.devze.com 2023-03-22 23:37 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Format .NET D开发者_C百科ateTime “Day” with no leading zero
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Format .NET D开发者_C百科ateTime “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


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


Just remove the extra M and d.


You can use "M/d/yy". See here for more details.


You can write X.ToString("M/d/yy")


It is X.ToString("M/d/y") if you want to remove ALL leading zeroes ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消