简体   繁体   English

错误:在C#中无法将字符串识别为有效的日期时间错误

[英]Error:string was not recognized as a valid datetime error in c#

Error:string was not recognized as a valid datetime error in c# 错误:在C#中无法将字符串识别为有效的日期时间错误

But I am using same code using in server system their working perfectly but in my local I got error so kindly 但是我在服务器系统中使用相同的代码可以完美地工作,但是在我的本地我很错误

MTL_REQD_BY_DATE = Convert.ToDateTime(mtlReqDate.Split('-')[1] + "-" + mtlReqDate.Split('-')[0] + "-" + mtlReqDate.Split('-')[2])

日期格式在本地计算机上必须不同。

It seems that the cultures of your system and the server are different. 您的系统和服务器的文化似乎不同。

Use the following approach for precise control: 使用以下方法进行精确控制:

DateTime date = DateTime.ParseExact(mtlReqDate, "dd-MM-yyyy", CultureInfo.Current);

Here is the description of the DateTime.ParseExact method. 是DateTime.ParseExact方法的描述。

An overview of custom date and time format strings can be found here . 可在此处找到自定义日期和时间格式字符串的概述。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C#错误“字符串未被识别为有效的DateTime” - C# error “String was not recognized as a valid DateTime” 字符串在 c# 错误中未被识别为有效的日期时间 - string not recognized as a valid datetime in c# ERROR c#DateTime转换错误-无法将字符串识别为有效的DateTime - c# DateTime convert error - String was not recognized as a valid DateTime Microsoft Edge-C#错误-无法将字符串识别为有效的DateTime - Microsoft Edge - C# Error - String was not recognized as a valid DateTime 收到错误:在C#中,字符串未被识别为有效的DateTime - Getting error : String was not recognized as a valid DateTime in c# 错误“字符串未被识别为有效的日期时间。” 在 c# - error “String was not recognized as a valid DateTime.” in c# 错误:在C#4中无法将字符串识别为有效的DateTime(格式) - Error :String was not recognized as a valid DateTime (Formating) in C# 4 该字符串未被识别为有效的DateTime错误 - The string was not recognized as a valid DateTime error c# 中的 DateTime 解析:获取“System.FormatException:”String 未被识别为有效的 DateTime”错误 - DateTime parsing in c#:getting a 'System.FormatException: 'String was not recognized as a valid DateTime' error C#将日期(年-月-年)转换为MM / dd / yyy错误字符串未被识别为有效的DateTime - C# Convert date (day-Month-year) to MM/dd/yyy Error String was not recognized as a valid DateTime
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM