SQL Server 日期格式 印度 到 美国
我有一项服务将日期从 SQL Server 数据库推送到 Web 数据库,推送的日期格式是“yyyyMMdd”。
我的数据库位于印度,因此日期格式和当前日期基于印度文化和区域设置。
我的网络服务器位于美国,因此日期格式基于美国。
印度和美国时间相差近13个小时。因此,当我的客户于 2011 年 6 月 13 日上午 9:00 输入货物时,网站上显示的日期是 6 月 12 日收到的货物。
因此,在客户预订之前收到货物会造成很大的麻烦。请指导我解决这个问题。
谢谢
I've a service which push date from my SQL server database to web database and the date format that is pushed is "yyyyMMdd".
My database resides in india, so date format and current date is based on Indian Culture and Locale based.
And my web server resided in US, so there the date format is based on US.
There is almost 13 hours difference in Indian and US time. So when my client entered a consignment on say 13 June 2011 9:00 am in the morning, it shows on website that is received on 12th June.
So receiving a consignment before client even booked them makes such a big hassle. Please guide me for something to reolve this.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将获取用户输入并将其转换为 UTC:
您可以将数据库中的所有
DateTime
值存储为 UTC,然后以适当的时区/文化将它们呈现给用户。This will take the user input and convert it to UTC:
You can store all
DateTime
values in your database as UTC and then present them to the user in whichever timezone / culture is appropriate.该交易确实于 6 月 12 日在美国发生,所以这实际上是正确的。
如果您希望该日期在美国查看时显示 6 月 12 日,在印度查看时显示 6 月 13 日,您需要将日期存储为 UTC 日期。
The transaction did actually happen on the 12th of June in the USA, so that is actually correct.
If you want that date to show 12th of june when viewed in the USA and the 13th of June when viewed in India you need to store your dates as UTC dates.