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

拥有回忆 提交于 2020-01-01 07:53:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!