Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74774 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75908 invoked from network); 6 Jun 2014 07:48:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2014 07:48:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=nicolai.scheer@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nicolai.scheer@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.43 as permitted sender) X-PHP-List-Original-Sender: nicolai.scheer@gmail.com X-Host-Fingerprint: 209.85.192.43 mail-qg0-f43.google.com Received: from [209.85.192.43] ([209.85.192.43:59034] helo=mail-qg0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AD/F1-63196-05271935 for ; Fri, 06 Jun 2014 03:48:33 -0400 Received: by mail-qg0-f43.google.com with SMTP id 63so3717131qgz.30 for ; Fri, 06 Jun 2014 00:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=Tny8HA2uPNNoq4EGD/ZLc/feAaH7nAXV+rvKhl641YE=; b=efD9ZSD2sIkxBEABl/9VHotfZThd8YQ02UJ4qtZSkCuGd/9In0wN4MT+hhBiZEPaFk T4vOVn6S3qf16gubjBDtz7SdfL10Qwt5m2iAe0gvmwfh/sXoTppt0OmZCWDHMdlS8VV9 PvBuU/KidsZH/tViSLh4Xf/VUlXDKTndAEc2PGuTQGsLCQbxzWaWOnZTpWkE/WpUOoab pvmzn/OmP8DcUa26d3o9sanLD24yZ4j4wTVBOCPEJTznRsxpy4tEP+CHGwqi9elVXz94 j5yONPOwdm9OFLuICzxpsIARBxuBNlI8T+ullsqNdOVhcxj+yPCXUly2cXCuhCo8VOHB E0Xg== MIME-Version: 1.0 X-Received: by 10.140.95.80 with SMTP id h74mr5394494qge.2.1402040910506; Fri, 06 Jun 2014 00:48:30 -0700 (PDT) Received: by 10.170.88.215 with HTTP; Fri, 6 Jun 2014 00:48:30 -0700 (PDT) Date: Fri, 6 Jun 2014 09:48:30 +0200 Message-ID: To: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: unix timestamps struggles with external library From: nicolai.scheer@gmail.com (Nicolai Scheer) 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