将字符串转换为datetime [英] Converting string to datetime
本文介绍了将字符串转换为datetime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法使用C#将MM / dd / yyyy字符串转换为日期时间。
我尝试了各种方法,但问题是当我转换日期时间格式是
dd / MM / yyyy而不是MM / dd / yyyy。
任何人都可以帮忙。
谢谢。
Hi,
Is there a way to Convert MM/dd/yyyy string to datetime using C#.
I have tried various methods but the problem is when I convert the datetime format is
dd/MM/yyyy and not MM/dd/yyyy.
Can anyone please help.
Thanks.
推荐答案
不,你的问题不同:没有阅读文档:
http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/ms131038.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/332de853.aspx [ ^ ]。
-SA
No, your problem is different: not reading documentation:
http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx[^],
http://msdn.microsoft.com/en-us/library/ms131038.aspx[^],
http://msdn.microsoft.com/en-us/library/332de853.aspx[^].
—SA
这样做的正确方法实际上是这个
The proper way to do this is actually this
var newValue = DateTime.ParseExact( "10/25/2000", "MM/dd/yyyy" );
这篇关于将字符串转换为datetime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文