日期分隔符问题 [英] Date separator issue
本文介绍了日期分隔符问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码
DateTime.Now.ToString("MM/dd/yyyy")
它总是给我这样的输出: 04.13.2011而不是 04/13/2011。我可以知道为什么会遇到这个奇怪的问题吗?
It always gives me this output : "04.13.2011" instead of "04/13/2011". May I know why I am getting this weird issue?
推荐答案
几乎可以肯定,您所处的文化是默认的日期分隔符。如果要强制 /
,则可以使用以下格式的字符串对其进行引用:
You're almost certainly in a culture where that's the default date separator. If you want to force /
you can quote it in the format string:
string x = DateTime.Now.ToString("MM'/'dd'/'yyyy")
这篇关于日期分隔符问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文