Hi!
I'm currently facing a strange problem, maybe someone is able to provide a hint.
I am working on a php extension that wraps the IBM message service
client for C/C++ [1].
Everything is working nice, except for one thing.
The library provides a function "getJMSTimestamp", which according to
the docs should be a standard unix timestamp (and therefor UTC) in
milliseconds.
The timestamp gets set, when the message is send, i.e. I do not set it myself.
I now send a message and fetch it right again afterwards. Now the
timestamp is off from what it should be.
To make it more complicated, the behaviour is not the same on windows and linux.
I wrote a plain C reproduction script to see if php is involved, and
it is, at least on linux.
Here are my findings:
My reference time is currently: 09:15:51 in Germany
I'm printing the current timestamp when sending the message (either
from the simple C program using time(NULL) or from within php using
time()
). I then print the timestamp of the received message. These
should match.
Windows Server 2008 (UTC +1:00 DST)
straight c
sending time(NULL)
1402038951
receipt timestamp
1402042551
from php
sending time()
1402038951
receipt timestamp
1402035351
Linux CentOs 6.5 (CEST)
straight c
sending time(NULL)
1402038951
receipt timestamp
1402038951
from php
sending time()
1402038951
receipt timestamp
1402035351
Good thing is, is does not matter where I call time()
/time(NULL), it
always gives me what I call the correct unix timestamp.
On Linux, the library seems to do the right thing when used
standalone. If php is involved, the timestamp is one hour off (DST?
UTC+1?).
On Windows the library standalone does weird things, again one hour
off, but in the other direction. Using php on windows yields the same
offset as on linux.
I'd like to file a bug report to IBM, but I need to somehow reproduce
the problem. If I send them my simple C example, they will only see
the wrong offset on windows, since it's seems correct on linux. That
does not explain the offset seen from within my php extension.
So my question is:
How does php affect C time functions? The result of that library
function differs when called from within a php extension and from
plain C code, so there must be a subtle difference in the php
environment.
I know this is a difficult question to ask, since I'm not able to
provide any additional information without the source code of the
library. Since using a plain time(NULL) in C does work in creating the
correct unix timestamp I can currently not imagine what the library
makes wrong (and why php affects that behaviour).
Ideas anyone?
Thanks for your help!
Greetings
Nico
PS:
I used php 5.5.12, both systems use "Europe/Berlin" as timezone for php
[1] http://www-01.ibm.com/support/docview.wss?uid=swg24007092