Pre-Epoch Dates

Pre-epoch dates are those that fall before Jan 1, 1970, which is the start of the "unix epoch". Timestamps in PHP are the number of seconds since the 1970, which works fine for most dates that you need to record. Things start to get tricky, however, when you need to track birth dates or other dates in the more distant past.

PHP does a very poor job of handling pre-epoch timestamps, and hence Propel also does a poor job. There are a couple problems with pre-epoch date handling in PHP:

  1. strtotime() will not correctly handle pre-epoch dates on any platform.
  2. Windows platforms can't use negative integers to represent pre-epoch dates.

To handle this shortcoming in PHP, a couple of special Propel column types were created. These column types do not get special (date/time) treatment by either Propel or the underlying Creole layer:

  • BU_DATE
  • BU_TIMESTAMP

(BU = Before Unix)

So, for example:

<column name="birthdate" type="BU_DATE" required="true"/>

Using these column types will result in SQL DDL that uses the correct DATE and TIMESTAMP native SQL types, respectively; however, the object model layer will not perform any smart date/time conversions for these columns and they will be treated like varchar (string) columns by the underlying Creole layer. This means that you must specify dates in a format that your database will understand. For example:

$person->setBirthdate('1985-01-01');