vb.net中的时区转换 [英] Time Zone Conversion in vb.net

查看:365
本文介绍了vb.net中的时区转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑构建一个应用程序,该应用程序可以通过电子邮件向您发送有关您一天的信息.服务器将检查应发送电子邮件的时间,然后发送.如果只有一个时区,但是不同的国家/地区具有不同的时区,则此方法非常有用.我目前正在使用(UTC)都柏林,爱丁堡,里斯本,伦敦.我的问题是,有没有办法在vb.net中转换TimeZones?

我尝试过这样的事情:

I''m thinking of building an application that can send you info over email about your day. The server will check the time that email should be sent and then send it. This method works great if there was only one time zone however different countries have different time zones. I''m currently using (UTC) Dublin, Edinburgh, Lisbon, London. My question is, is there a way to convert TimeZones in vb.net?

I tried something like this:

Dim ZoneId As String = "Central America"
Dim localtime As DateTime = DateTime.Now
Dim timeZoneInfo As TimeZoneInfo = System.TimeZoneInfo.FindSystemTimeZoneById(ZoneId)
Dim dataTimeByZoneId As DateTime = System.TimeZoneInfo.ConvertTime(localtime, System.TimeZoneInfo.Local, timeZoneInfo)
Return dataTimeByZoneId



但是似乎没有任何效果.

在此先感谢您!



But nothing seems to be working.

Thanks in advance!

推荐答案

我认为您的应用程序中有Country表.您可以再加上一个列名timezone.您可以存储与国家/地区相关的时区的值,并且在发送邮件期间,可以使用MYSQL的convert_tz()函数将应用程序时区转换为所选国家/地区"时区,如果满足要求,则可以发送邮件. >
有关convert_tz()的信息,请参见下面的链接:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_convert-tz [
I think You have Country table into your application. You can take one more column name timezone . You can store the Value of timezone Related to country, and during sending mail you can use convert_tz() function of MYSQL to convert your application timezone into Selected Country time Zone, and if it is satisfied then You can send the mail.

For Infomation About convert_tz(), See the Below Link:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_convert-tz[^]

Hope this will Help You.


这篇关于vb.net中的时区转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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