| 
	
 | 
 Posted by Otis on 09/04/07 07:38 
PHP is driving me mad with their idiotic way of dealing with dates and  
date conversions - unless I'm the idiot. 
 
Here's what I need: 
 
Let's assume the date is $d = "09/03/1951" - Sep 3, 1951 
 
How do I get just the year from a date like Sep 3, 1951? 
How do I get just the day from a date like Sep 3, 1951? 
How do I get just the month from a date like Sep 3, 1951? 
 
I have never been able to get PHP to deal properly with the years since  
it seems to have the stupid habit of deciding for itself whether a year  
is 2000 something or 1900 something. It apparently only wants to deal  
with 2-digit years. 
 
Here is what I have done in the past when I needed a FULL date: 
 
   if ($inyear >= 2000) 
   { 
     $utdatenow = strftime("%d.%m.20%y", mktime($inhours, $inmins,  
$insecs, $inmonth, $inday, $inyear)); 
   } 
   else 
   { 
     $utdatenow = strftime("%d.%m.19%y", mktime($inhours, $inmins,  
$insecs, $inmonth, $inday, $inyear)); 
   } 
 
How cumbersome!!! 
 
Isn't PHP/UNIX smart enough to know what the 4-digit year is without me  
having to jump through hoops? 
 
In Visual Basic it was simple: 
 
yr$ = Year("09/03/1951") gave me 1951 
dy$ = Day("09/03/1951") gave me 3 
mo$ = Month("09/03/1951") gave me 9 
 
Why isn't PHP as straight-forward? 
 
 
Thank you. 
 
 
Otis
 
[Back to original message] 
 |