[ciapug] Strtotime, and dates prior to 1970
Jerry Weida
ciapug@cialug.org
Fri, 09 Jan 2004 10:24:57 -0600
Don't usually like having to caculate dates, but in this instance, if we are just adjusting the way it's being displayed, then I wouldn't even bother with the date(). Just break apart the string itself.
function mkSlashdate($vStamp) {
if ($vStamp) {
list($date,$time) = split(" ",$vStamp);
list($year,$month,$day) = split("-",$date);
$slashDate = $month . "/" . $day . "/" . $year;
return $slashDate;
} else {
echo "No time stamp received.<p>";
}
}
Chris Hettinger wrote:
>.. 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 = 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
>
>
>
>
>
>-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.'
>
>_______________________________________________
>ciapug mailing list
>ciapug@cialug.org
>http://cialug.org/mailman/listinfo/ciapug
>
>