如何设置日期格式 [英] How do I set date format
本文介绍了如何设置日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
string dateToformat = "dd/MM/yyyy";
DateTime dateTo = DateTime.ParseExact(DateTo.Text, dateToformat, CultureInfo.InvariantCulture);
错误是字符串不是一个有效的日期时间。
Error is string was not a valid datetime.
推荐答案
DateTime paid = new DateTime();
System.Globalization.CultureInfo Cul = new System.Globalization.CultureInfo("en-GB", true);
paid = DateTime.Parse(txtpaiddate.Text.Trim(), Cul, System.Globalization.DateTimeStyles.NoCurrentDateDefault);
您输入的日期字符串格式不正确。
尝试DateTime .TryParse
http:/ /msdn.microsoft.com/en-us/library/system.datetime.tryparse%28v=vs.110%29.aspx [ ^ ]。
The date string you input is not in the correct format.
TryDateTime.TryParse
http://msdn.microsoft.com/en-us/library/system.datetime.tryparse%28v=vs.110%29.aspx[^].
先生,而不是所有这些努力尝试这个
sir, instead of all these efforts try this
DateTime Dt = DateTime.Parse("03/02/2014").ToString("dd/MM/yyyy");//At the Last in the string function you specify what is the date format
这篇关于如何设置日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文