本文介绍了字符串到日期时间的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想将字符串"27/06/2012"转换为datetime.
任何人都可以帮忙吗??
我尝试使用Datetime.parseexact方法,但是给出了错误的日期.


i would like to convert the string "27/06/2012" to datetime .
Can any body please help.?
I Tried using Datetime.parseexact Method , but it is giving wrong date.

推荐答案

DateTime myDate = DateTime.ParseExact("27/06/2012", "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture)




Or

DateTime oDate = DateTime.Parse(string s);



参考:
Convert.ToDateTime方法(字符串) [ ^ ]

我尝试使用Datetime.parseexact方法,但日期输入错误.
它确切给出的是,您可以张贴那个错误的日期吗.



Refer:
Convert.ToDateTime Method (String)[^]

I Tried using Datetime.parseexact Method , but it is giving wrong date.
What exactly it''s giving, can you post that wrong date.


Convert.ToDateTime("27/06/2012");



我希望它能正常工作.....



I hope it will work.....


这篇关于字符串到日期时间的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 11:52