[EMAIL PROTECTED] wrote:
> All,
> 
> I have this code:
> 
> my ($month, $day, $year) = (localtime)[4,3,5];
> printf ("%02d/%02d/%02d\n", $month+1,$day,$year+1900);
> 
> which gives me
> 
> 08/16/2004
> 
> what I want is 08/16/04.  Should I just use Posix with strftime or is
> there a quicker way w/out having to load the Posix module?

   ($year + 1900) % 100

> 
> also, why I ntoiced I had to may $month+1 otherwise it outputs a month
> back.  why is this?

Historic localtime(3) semantics. Not really sure how it got that way, but
that's the way it is. Maybe because the value would typically be used to
index an array in C, which uses zero-based arrays?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to