Zend Framework

Zend_Date's methods getTimestamp() and get(Zend_Date::TIMESTAMP) return different values if date is outside the year range of 1901 to 2038

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: 1.9.2
  • Fix Version/s: 1.10.0
  • Component/s: Zend_Date
  • Labels:
    None

Description

On my system PHP's date() function can handle dates roughly between the dates 1901 to 2038. Zend_Date also works fine inside this same range but when a date is outside this range the returned unix timestamp produced by calling get(Zend_Date::TIMESTAMP) had the timezone offset added to the timestamp, which is wrong. Code to prove this:

date_default_timezone_set('EET');
//December 6th 1917 10:10:10
$timestamp = '-1643212190';
$dateObj = new Zend_Date($timestamp);
echo $timestamp . "\n";
echo $dateObj->getTimestamp() . "\n";
echo $dateObj->get(Zend_Date::TIMESTAMP) . "\n";
//December 6th 1817 10:10:10
$timestamp = '-4798885790';
$dateObj = new Zend_Date($timestamp);
echo $timestamp . "\n";
echo $dateObj->getTimestamp() . "\n";
echo $dateObj->get(Zend_Date::TIMESTAMP);

This produces the output:

-1643212190
-1643212190
-1643212190
-4798885790
-4798885790
-4798878590

Why is the last unix timestamp not the same when calling get(Zend_Date::TIMESTAMP) and calling getTimestamp() when the date is outside the year range of 1901 to 2038? Dates inside this year range get correctly the same unix timestamp from both methods.

Issue Links

Activity

Hide
Thomas Weidner added a comment -

Duplicate of already fixed issue.

Show
Thomas Weidner added a comment - Duplicate of already fixed issue.
Hide
Robin Lindroos added a comment -

Could somebody please explain to me why this behavioir is correct? Why does getTimestamp() and get(Zend_Date::TIMESTAMP) return the same unix timestamp when the date is inside the year range of 1901 to 2038, but they return different values when the date is outside this year range?

Show
Robin Lindroos added a comment - Could somebody please explain to me why this behavioir is correct? Why does getTimestamp() and get(Zend_Date::TIMESTAMP) return the same unix timestamp when the date is inside the year range of 1901 to 2038, but they return different values when the date is outside this year range?
Hide
Thomas Weidner added a comment -

Running your example code on SVN the following is returned:

-1643212190
-1643212190
-1643212190
-4798885790
-4798885790
-4798885790

As this issue is marked as fixed for the next minor release I don't see a problem as all works like it should.

Show
Thomas Weidner added a comment - Running your example code on SVN the following is returned:
-1643212190
-1643212190
-1643212190
-4798885790
-4798885790
-4798885790
As this issue is marked as fixed for the next minor release I don't see a problem as all works like it should.
Hide
Robin Lindroos added a comment -

Ok, so there was a bug. I did not understand that from your first comment. I thougt you sed it SHOULD work like I had reported But ok, thanks for this!

Show
Robin Lindroos added a comment - Ok, so there was a bug. I did not understand that from your first comment. I thougt you sed it SHOULD work like I had reported But ok, thanks for this!
Hide
Thomas Weidner added a comment -

You gave the second example at a time where the other issue was already closed for the next minor release.
And at night I normally sleep... therefor the delay in the response

Show
Thomas Weidner added a comment - You gave the second example at a time where the other issue was already closed for the next minor release. And at night I normally sleep... therefor the delay in the response

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: