使用C#将UTC转换为IST [英] Convert UTC to IST using C#

查看:54
本文介绍了使用C#将UTC转换为IST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将特定UTC时间转换为IST时间.但是,我得到的日期与输出的日期相同.

I have tried to convert a Specific UTC time into IST time. But, I got the same date as the output.

//utcdate是2014年6月15日上午12:00:00

var istdate = TimeZoneInfo.ConvertTimeFromUtc(utcdate,
              TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));

输出:2014年6月15日上午12:00:00

您能指导我解决此问题吗?

Could you please guide me to resolve this issue?

推荐答案

尝试一下:

DateTime utcdate = DateTime.ParseExact("6/15/2014 12:00:00 AM", "M/dd/yyyy 
                                       h:mm:ss tt",CultureInfo.InvariantCulture);
var istdate = TimeZoneInfo.ConvertTimeFromUtc(utcdate,
TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));

我正在输出:

6/15/2014 5:30:00 AM

这篇关于使用C#将UTC转换为IST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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