日期时间字符串格式错误 [英] Date Time String Format incorrect

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

问题描述

大家好,


$ b $我试图将日期时间解析为文本框但是它给出了以下错误;



System.FormatException:String未被识别为有效的DateTime。在System.DateTimeParse.Parse(String s,DateTimeFormatInfo dtfi,DateTimeStyles样式)在System.DateTime.Parse(String s)at Administration_Manage_Members_FormsView_MemberPlan.btnSubmit_Click(Object sender,EventArgs e)



这里是我使用的代码;

Hi Everyone,

i am trying to parse a date time to a text box but it give the error below;

System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.DateTime.Parse(String s) at Administration_Manage_Members_FormsView_MemberPlan.btnSubmit_Click(Object sender, EventArgs e)

here is the code i used;

DateTime dttxtInceptionDate = DateTime.Parse(txtInceptionDate.Text.Trim());



感谢您的帮助......


Thanks for your help....

推荐答案

您好,试试这个:



Hi, try to use this:

string date = txtInceptionDate.Text;
DateTime dttxtInceptionDate = Convert.ToDateTime(date);











OR

string date = txtInceptionDate.Text;
DateTime dttxtInceptionDate = DateTime.Parse(date);


我们需要知道你在txtInceptionDate.Text中输入了什么文本。



使用Convert.ToDateTime
we need to know what text you are entering in txtInceptionDate.Text.

use Convert.ToDateTime


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆