SQL Server中的日期持续12小时

时间:2022-06-24 08:53:23

Our production platform technologies are these: PHP, MS SQL Sever, and IIS.

我们的生产平台技术包括:PHP,MS SQL Sever和IIS。

PHP is set to the timezone 'Pacific/Auckland' which is current +12:00 GMT/UTC.

PHP设置为时区'Pacific / Auckland',当前+12:00 GMT / UTC。

When we retrieve dates from SQL Server, they are consistently 12 hours 'behind' what they should be, ie. SQL Server is storing and serving them as GMT dates, even though the time zone on the server itself is Pacific/Auckland too.

当我们从SQL Server中检索日期时,它们应始终落后12小时,即。 SQL Server正在存储和提供它们作为GMT日期,即使服务器本身的时区也是太平洋/奥克兰。

Is there a hidden sp function some where you can use to set the timezone? If this is not timezone related, please enlighten me!

是否有隐藏的sp功能,您可以使用它来设置时区?如果这不是时区相关的,请赐教!

2 个解决方案

#1


Can you open up sql server management studio and type "select getdate()" to make sure it is sql server that is wrong?

你能打开sql server management studio并输入“select getdate()”来确保它是sql server错了吗?

Are you using getdate() or another sql function to get the date?

您是否使用getdate()或其他sql函数来获取日期?

#2


If your statement is both accurate and general, then you should be able to reproduce this simply by inserting a row into a table with a datetime column like this:

如果您的语句既准确又通用,那么您应该能够通过在具有datetime列的表中插入一行来重现这一点,如下所示:

CREATE TABLE OffBy12 (
    IsThisOff datetime not null
)
GO

INSERT INTO OffBy12 (IsThisOff) VALUES ('2009-06-28')

SELECT IsThisOff
FROM OffBy12

If you're right, then the time portion of the date will not be 00:00.

如果你是对的,那么日期的时间部分将不是00:00。

If you're not correct, then this must be something more complex. In that case, you may want to say how the data are getting into SQL Server.

如果你不对,那么这一定是更复杂的事情。在这种情况下,您可能想说明数据是如何进入SQL Server的。

#1


Can you open up sql server management studio and type "select getdate()" to make sure it is sql server that is wrong?

你能打开sql server management studio并输入“select getdate()”来确保它是sql server错了吗?

Are you using getdate() or another sql function to get the date?

您是否使用getdate()或其他sql函数来获取日期?

#2


If your statement is both accurate and general, then you should be able to reproduce this simply by inserting a row into a table with a datetime column like this:

如果您的语句既准确又通用,那么您应该能够通过在具有datetime列的表中插入一行来重现这一点,如下所示:

CREATE TABLE OffBy12 (
    IsThisOff datetime not null
)
GO

INSERT INTO OffBy12 (IsThisOff) VALUES ('2009-06-28')

SELECT IsThisOff
FROM OffBy12

If you're right, then the time portion of the date will not be 00:00.

如果你是对的,那么日期的时间部分将不是00:00。

If you're not correct, then this must be something more complex. In that case, you may want to say how the data are getting into SQL Server.

如果你不对,那么这一定是更复杂的事情。在这种情况下,您可能想说明数据是如何进入SQL Server的。