如何在邮件中发送本地时间? [英] How to send the recepients local time in mails ?

查看:162
本文介绍了如何在邮件中发送本地时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将收件人的当地时间发送到电子邮件的正文中。我的电子邮件的正文是html内容。并且通过我的c#代码在html主体中传递一些变量,如date等。有什么格式的DateTime,我可以通过,将被自动转换为本地时间的邮箱或我可以在html / javascript中做什么,这将动态转换为收件人当地时间的接收时间?

I have to send the local time of the recipient in the body of a e-mail. The body of my email is html content. And am passing some variables like date etc in the html body through my c# code. Is there any format of DateTime that I can pass which will be automatically converted to local time by the mailbox or something that I can do in html/javascript which will dynamically convert the time into recepients local time when the mail is received?

谢谢

推荐答案

正如你无疑会发现的。 DateTime操作很难,因为您需要考虑到无数的事情。

As you will undoubtedly find out. DateTime manipulation is hard because of the myriad things you need to take into account.

什么是用户时区?
他们是否观察夏令时?

等...

确保使用内置的.Net

Make sure you are using the built in .Net TimeZoneInfo class to convert from one time to another. For instance, if you want to convert from your current time to "Central Standard Time" you would do it like this.

var central = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, central);

这篇关于如何在邮件中发送本地时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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