如何将这个5时41分33秒2012年4月23日PDT值转换为datetime在C#中? [英] How to convert this 05:41:33 Apr 23, 2012 PDT value to datetime in C#?

查看:320
本文介绍了如何将这个5时41分33秒2012年4月23日PDT值转换为datetime在C#中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/241789/parse-datetime-with-timezone-of-form-pst-cest-utc-etc\">Parse日期时间与形式的PST / CEST / UTC /等结果时区
  如何转换PDT时间字符串为DateTime

我想这个值五点41分33秒4月23日转换,2012 PDT为datetime。

I want to convert this value 05:41:33 Apr 23, 2012 PDT to datetime .

我试图这一点,但它给错误。

i am trying this but it is giving an error.

 DateTime dt = Convert.ToDateTime("05:41:33 Apr 23, 2012 PDT");

请帮我人怎样才能在C#中做到这一点。

Please help me guys how we can do it in C#.

谢谢,Rajbir

推荐答案

PDT 是无法识别通过的任何的解析的时区在BCL为的DateTime 选项。

The PDT is not recognizable as a timezone by any of the parsing options for a DateTime in the BCL.

如果您解析之前,将其转换为 -0700 它将解析ok了。

If you convert it to -0700 before parse it will parse ok.

string correctedTZ = "05:41:33 Apr 23, 2012 PDT".Replace("PDT", "-0700");
DateTime dt = Convert.ToDateTime(correctedTZ);

这篇关于如何将这个5时41分33秒2012年4月23日PDT值转换为datetime在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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