473,670 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Timezone confusion

I'm using PHP4 and have got myself confused over timezones.

I've put a datetime into my MySQL table as a GMT time. MySQL shows me
the data as '2007-04-06 16:04:56'. I put that in there just after 5pm,
and as I'm in London (GMT+0), but we're now on British Summer Time
(GMT+1), that appears to be correct.

I want to get that datetime out again, and print it into my webpage,
keeping it as GMT. i.e. I want PHP to treat that time as '2007-04-06
16:04:56'. If I say:

$date = date( 'r', $timestamp );

then it says:

Fri, 06 Apr 2007 16:04:56 +0100

The time is right, but it's reporting my local timezone. If I say:

$date = gmdate( 'r', $timestamp );

then it says:

Fri, 06 Apr 2007 15:04:56 +0000

Now it's got the timezone as I want it (+0000, which is GMT) but the
time is wrong.

It seems that PHP's gmdate() treats the input timestamp value as being
local time, and therefore corrects it by either marking it with the
local timezone (as per the date() function), or 'correcting' it to GMT
(as per the gmdate() function).

Either way, given that I'm starting with an absolute, GMT based time
stamp, this isn't helpful!

I *think* I've got the right timestamp in my MySQL table, and *think*
I'm interpreting the datetime incorrectly in PHP. Can someone explain
where I'm going wrong and how I get PHP to just convert my GMT date/time
number to a GMT date/time string?

--
Derek Fountain on the web at http://www.derekfountain.org/
Apr 6 '07 #1
0 1342

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1349
by: Jason Kinkade | last post by:
I recently installed MySQL 4.0.18 on my slackware 9.1 machine (kernel 2.4.25) by compiling the source. It works fine, and all tests pass except one. The timezone test. Can someone tell me why I'm getting this error? Is there something with the TZ variable I have to set for the shell? I think its EDT right now. timezone Errors are (from /custompath/mysql/mysql-test/var/log/mysqltest-time)
7
3200
by: Jim Davis | last post by:
I'm (still) working on an ISO 8601 date parser. I want to convert at least the formats described here: http://www.w3.org/TR/NOTE-datetime Well.. I've got most of it working (via RegEx's) good enough for me but I'm having a brain block when it comes to TimeZone. The datetime may come with an optional timezone offset (from GMT) as here (the offset is +1 hour from GMT):
1
4019
by: cnliou | last post by:
Hi! If I correctly understand v7.4 manual, value, say, '2003-11-26 12:00' in TIMESTAMP WITHOUT TIMEZONE column should output '2003-11-26 19:00' for "+08:00" timezone. The following test results seem to be somewhat unexpected. Restting OS timezone (/etc/timezone and /etc/localtime in Linux) does not make the results more comfortable.
1
2546
by: Raj Chudasama | last post by:
I have the following code for a clock in my gui. Everything works fine EXCEPT the following line when the TimeZone is changed in the windows. string tz = TimeZone.CurrentTimeZone.StandardName; It will not pick the changed timezone but it does pick up time change due to timezone change.
13
14459
by: Stuart Bishop | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi. I'm trying to determine the best way of saying 'The current time in UTC with no time zone information'. I'm currently using CURRENT_TIMESTAMP AT TIME ZONE 'UTC' and inserting into columns defined as TIMESTAMP WITHOUT TIME ZONE which appears to
2
4757
by: David Garamond | last post by:
When a timestamp string input contains a timezone abbreviation (CDT, PST, etc), which timezone offset is used? The input date's or today date's? The result on my computer suggests the latter. # create table ts (ts timestamptz); # insert into ts values ('2004-10-17 00:00:00 CDT'); -- UTC-5 # insert into ts values ('2004-11-17 00:00:00 CDT'); -- UTC-6 # select ts at time zone 'utc' from ts; timezone ---------------------
13
2848
by: Bruno Wolff III | last post by:
Recently there has been some discussion about attaching a timezone to a timestamp and some other discussion about including a 'day' part in the interval type. These two features impact each other, since if you add a 'day' to a timestamp the result can depend on what timezone the timestamp is supposed to be in. It probably makes more sense to use a timezone associated with the timestamp than say the timezone GUC or the fixed timezone UTC. ...
3
8318
by: asanford | last post by:
I want to create a web service that allows the caller to pass a DateTime to the web service (that is, create a web method such as void MyWebMethod(DateTime dt).) However, I want to be able to capture the TimeZone of the caller as well - but I don't want the interface to specify an xs:string as the method argument - I want it to use an xs:dateTime type argument. Now, I know when a DateTime structure is serialized into XML it becomes an...
2
3683
by: =?Utf-8?B?Sm9ubnk=?= | last post by:
I have an ASP.NET 2.0 C# web application that is contacting an Exchange server using WEBDAV. It allows the users to look up appointments for a future date. The problem I have is determining the correct client time zone. Note that Exchange stores everything in UTC time. I am able currently able to use javascript to ask the client what time zone they are in, but this is only for the "today" (the current day) and not for a day in the...
0
8466
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8901
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5683
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4388
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1791
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.