开发者

How to send reminder emails based on users input time and day (based on their time zone)

开发者 https://www.devze.com 2022-12-24 05:54 出处:网络
I need to send emails based on users input time and day (based on their time zone)? Kind of a reminder.

I need to send emails based on users input time and day (based on their time zone)? Kind of a reminder.

For Example: User input 2:00pm Eastern Time on my server I have different time zone, how to calculate the time and send the email at users time-zone.

Its a web application. What is the best way to accomplish it using asp.net c#? If somebody already done it in the past I will be glad to tak开发者_如何学运维e a look at source code. Thank you for useful suggestions.


Anytime timezone matters, store and manipulate the dates as UTC. If the user asks to have an email sent at 2PM EST, send it at 18:00 UTC (EST is -5 UTC).

You will need to determine their timezone by either asking for it or, perhaps, by figuring it out using something like http://ipinfodb.com (based on IP address).

In .Net you can convert the time using the TimeZoneInfo object.

var local = new DateTime(DateTime.Now.Ticks, DateTimeKind.Unspecified);
var tzi = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
var utc = TimeZoneInfo.ConvertTimeToUtc(local, tzi);
0

精彩评论

暂无评论...
验证码 换一张
取 消