[已解决] XML日期时间转换问题 [英] [Solved] XML Date Time Conversion Issue

查看:102
本文介绍了[已解决] XML日期时间转换问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的过程之一中,我正在获取XML,该XML具有节点ProductName和DeliveryDate.

在我的程序中,它解析XML并将其插入到一个表中,该表具有一个NVARCHAR和一个Datetime Column.

在XML中,我正在获取格式为(2011-02-16T11:08:00 + 05:30)的日期

请让我知道如何将其转换为(2011-02-16 11:08:00)

我试图用空白处替换T和+05:30,
但是每次+5:30都不是恒定的.

In one of my procedure , I am getting XML , Which have node , ProductName , DeliveryDate .

In my proceudre It parse the XML and insert into one table which having one NVARCHAR and one Datetime Column.

In the XML I am getting the date in format (2011-02-16T11:08:00+05:30)

Please let me know how can I convert it into (2011-02-16 11:08:00)

I have tried to replace the T and +05:30 with blank places ,
but everytime +5:30 is not constant.

推荐答案

以空格代替+05:30失败了,这太好了,您尝试过. br/>
这是时区.如果没有时区,则您具有本地时间,但是如果事件发生在全球不同地方,则会失去及时订购事件的能力.如您所见,+ 5:30不是常数,在您的应用程序中就是这种情况.

您没有指定使用的平台,语言和库,但总而言之,您需要将所有时间都转换为世界协调时间(i)"(UTC)http://en.wikipedia.org/wiki/Coordinated_Universal_Time [
It''s good that you failed replacing +05:30 with blank spaces and too bad you tried.

This is the time zone. Without the time zone, you have the local time but loose the ability to order different events in time if they happen in different places of the globe. As you noticed +5:30 is not a constant, this is the case in your application.

You did not specify your platform, languages and the libraries you use, but in a nutshell, you need to transform all times into Coordinated Universal Time (UTC) http://en.wikipedia.org/wiki/Coordinated_Universal_Time[^] using the time zone information. Depending on your application, you may need need to store time zone information separately in your database, if you need to generate local time for your users. All modern calendar libraries have the features to accomplish it.

—SA


这篇关于[已解决] XML日期时间转换问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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