C#解析日期时间"周五2011年1月14日14时56分36秒格林尼治标准时间0800(太平洋标准时间)QUOT; [英] c# parse datetime "Fri Jan 14 2011 14:56:36 GMT-0800 (Pacific Standard Time)"
本文介绍了C#解析日期时间"周五2011年1月14日14时56分36秒格林尼治标准时间0800(太平洋标准时间)QUOT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在做
DateTime的DT = DateTime.ParseExact(stringDate,DDD MMM DD YYYY HH:MM:SS UTCzzzzz ZZZZ,System.Globalization.CultureInfo.InvariantCulture);
但是,这是产生误差(误差在该日期被不正确格式)。 ?难道你们知道正确的语法是什么
日期为:
周五2011年1月14日15点零零分39秒格林尼治标准时间0800(太平洋标准时间)
块引用>
解决方案这似乎是,如果你带了字符串的结尾工作。
VAR stringDate =周五2011年1月14日15时: 39 GMT-0800;
VAR DT = DateTime.ParseExact(
stringDate,
DDD MMM DD YYYY HH:MM:SS'GMT'zzz,
System.Globalization.CultureInfo.InvariantCulture);
I'm doing
DateTime dt = DateTime.ParseExact(stringDate, "ddd MMM dd yyyy HH:mm:ss UTCzzzzz zzzz", System.Globalization.CultureInfo.InvariantCulture);
But, that is generating an error (the error was that date was not in the correct format). Do you guys know what the correct syntax is?
The date is:
Fri Jan 14 2011 15:00:39 GMT-0800 (Pacific Standard Time)
解决方案This seems to work if you strip the end of the string.
var stringDate = "Fri Jan 14 2011 15:00:39 GMT-0800"; var dt = DateTime.ParseExact( stringDate, "ddd MMM dd yyyy HH:mm:ss 'GMT'zzz", System.Globalization.CultureInfo.InvariantCulture);
这篇关于C#解析日期时间"周五2011年1月14日14时56分36秒格林尼治标准时间0800(太平洋标准时间)QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文