I am trying to store dates in my database as a UNIX timestamp but there appears to be a problem saving (or converting) older dates.
For example, trying to save a date of 01/01/1854 (1St Jan 1854) doesn't work, I think. I say I think as the resulting conversion produces nothing.
Here's my code:
My input box accepts the date '01/01/1854'
I then
If I echo the $dobDate, it produces nothing.
If I put the date of 01/01/2011 in the input field the UNIX timestamp is successful.
So, I would deduce from this that the older dates are out of range??
The PHP manunal states:
I'm using PHP 5.2.14
If there is no way of converting this date (or even older dates) into UNIX timestamps, how is it best to store these dates?
For example, trying to save a date of 01/01/1854 (1St Jan 1854) doesn't work, I think. I say I think as the resulting conversion produces nothing.
Here's my code:
My input box accepts the date '01/01/1854'
I then
Code:
$dob = $_POST['dob'];
$dob_date_parts = explode("/",$dob);
$newdob = $dob_date_parts[2] . "-" . $dob_date_parts[1] . "-" . $dob_date_parts[0];
$dobDate = strtotime($newdob);
If I put the date of 01/01/2011 in the input field the UNIX timestamp is successful.
So, I would deduce from this that the older dates are out of range??
The PHP manunal states:
The last line of this I presume means that if I have PHP 5.1.0 or newer, I can any date in this variable???PHP Manual said:The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems. PHP 5.1.0 and newer versions overcome this limitation though.
I'm using PHP 5.2.14
If there is no way of converting this date (or even older dates) into UNIX timestamps, how is it best to store these dates?