在 vbscript 中处理时区 [英] Dealing with timezones in vbscript

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

问题描述

我正在尝试使用 vbs 更改一些旧的 .asp 文件.我们的数据库将被转换为以 UTC 格式存储日期,但在网页上它应该以欧洲/赫尔辛基"时区显示日期和时间(

TimeZoneInfo.FindSystemTimeZoneById("FLE 标准时间")

在 C# 中).如何使用 vbscript 将我从 db 查询中获得的 UTC 日期(查询也在 .asp 文件中运行,并将结果放入表中)以更正日期时间?

解决方案

只需使用 DateAdd().

Const EETOffset = -2 'EET 与 UTC 的偏移量为 -2 小时Dim dbDateValue '来自数据库的假定值昏暗的新日期'... 填充 dbDateValue 的数据库进程newDate = DateAdd("h", EETOffset, dbDateValue)

<块引用>

注意:这种方法的一个问题是您还必须根据时间手动补偿 EET 和 EEST (东欧夏令时间)年.当您考虑到某些地方不使用它而全年使用 EET 时,这也更加困难.
请参阅EET – 东欧时间(标准时间).

根据您使用的 RDMS,您甚至应该能够在日期作为初始查询的一部分到达页面之前对其进行操作.


有用的链接

I'm trying to change some old .asp files with vbs. Our database is going to be converted to store dates in UTC, but on webpages it should show dates and time in "Europe/Helsinki" timezone(

TimeZoneInfo.FindSystemTimeZoneById("FLE Standard Time")

in c#). How can I cast the UTC date I get from db query( the query is run in the .asp file as well and the result put into table) to correct date time using vbscript?

解决方案

Just offset the UTC dates using DateAdd().

Const EETOffset = -2 'EET offset from UTC is -2 hours
Dim dbDateValue  'Assumed value from DB
Dim newDate
'... DB process to populate dbDateValue
newDate = DateAdd("h", EETOffset, dbDateValue)

Note: One problem with this approach is you will also have to compensate for EET and EEST (Eastern European Summer Time) manually based on the time of year. Which is also more difficult when you take into consideration some places don't use it and use EET all year round instead.
See EET – Eastern European Time (Standard Time).

Depending on the RDMS you are using you should even be able to manipulate the dates before they get to the page as part of the initial query.


Useful Links

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

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