[ciapug] Strtotime, and dates prior to 1970
Chris Hettinger
ciapug@cialug.org
Fri, 9 Jan 2004 09:42:58 -0600
.. I have a function that I pass a unix timestamp (YYYY-MM-DD HH:MM:SS) =
... and it returns a date formatted as (MM/DD/YYYY) for diplay =
reasons... Curious if anyone has a nifty way around the issue that =
strtotime() will not work with dates prior to 1970, the Unix epoch date. =
Below is the function and the date that I passed it.
I thought I can add something that will check the year value within the =
timestamp, and then if it prior to 1970 do a bit more work tearing apart =
the timestamp and reconstructing it in the format I need... just =
wondering if anyone has solution they found?
function mkSlashdate($vStamp) {
if ($vStamp) {
$date =3D date("m/d/Y", strtotime($vStamp));
return $date;
} else {
echo "No time stamp received.<p>";
}
}
Sent as: 1950-04-07 00:00:00
Returned as: 12/31/1969=20
-Chris Hettinger, Web Specialist
-IFMC/ENCOMPASS
-www.encompas.com
-(515) 279-8730
CONFIDENTIALITY NOTICE: This communication, including any attachment, =
may contain confidential information and is intended only for the =
individual or entity to whom it is addressed. Any review, =
dissemination, or copying of this communication by anyone other than the =
intended recipient is strictly prohibited. If you are not the intended =
recipient, please contact the sender by reply email, delete and destroy =
all copies of the original message.'