Jump to content

Recommended Posts

Hi All,

 

I have this timestamp which is sent to me but an API. It is created by java code.

 

$timestamp = -2174688000000;

 

I know this date is Feb 2, 1901. This converter shows me the date..

 

http://www.ewert-technologies.ca/online_tools/timestamp_converter.html

 

$timestamp = -2174688000000;
$timestamp /= 1000;
echo date("D d M Y - H:i:s", $timestamp);

 

But using the php date() function it gives me Dec 13th, 1901. What is going on here? Am i missing something?

 

I have checked timezones are the same. The date was created on on a server with the same timezone.

 

 

Any help would be greatly appreciated.

 

Thanks

 

 

It is a constraint with PHP. From the manual date():

 

Changelog:

5.1.0: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer). However, before PHP 5.1.0 this range was limited from 01-01-1970 to 19-01-2038 on some systems (e.g. Windows).

Thanks, that clears that issue up, i must have missed that in the manual. Here is another..

 

$timestamp = -116463600000;
$timestamp /= 1000;
echo date("D d M Y - H:i:s", $timestamp);

 

This is returned by a java API also. Java interprets this as September 10th 1973. The above converter also does, based on GMT. But running this timestamp through PHP on a GMT based server gives September 9th 1973.

 

Why the difference in the days? Both are run on GMT.

With php, mysql, and 2-3 online tools I found, 116463600 gives the following -

 

php - Sep 9, 1973 23:00:00

mysql - 1973-09-09 23:00:00

http://www.epochconverter.com/ - Sun, 09 Sep 1973 23:00:00 GMT

http://www.onlineconversion.com/unix_time.htm - Sun, 09 Sep 1973 23:00:00 GMT

http://www.4webhelp.net/us/timestamp.php - Sunday, September 9th 1973, 23:00:00 (GMT)

 

I would say that the web site you are using that is giving Sep. 10th is trying to do math to come up with the GMT value and is not taking into account a DST offset.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.