http://qs321.pair.com?node_id=306675


in reply to Help with dates

Just use localtime:
my ($mday, $mon, $year, $wday) = (localtime)[3..6]; $mon += 1; $year += 1900;
Of course, this leaves you with a 4-digit year, but that's easy enough to fix:
$year =~ s/^\d\d//;
See perldoc -f localtime for more information.

Update: Modified to include $wday and perldoc reference.

If things get any worse, I'll have to ask you to stop helping me.

Replies are listed 'Best First'.
Re: Re: Help with dates
by thelenm (Vicar) on Nov 12, 2003 at 23:59 UTC

    Of course, this leaves you with a 4-digit year, but that's easy enough to fix:

    You mean that's easy enough to unfix. :-) I don't know why people still use 2-digit years, but I guess if that's what the OP wants...

    -- Mike

    --
    XML::Simpler does not require XML::Parser or a SAX parser. It does require File::Slurp.
    -- grantm, perldoc XML::Simpler

      I'm with you, and I originally wasn't even going to address the issue. But the OP's specs call for a 2-digit year, and far be it from me to violate specs. ;)

      If things get any worse, I'll have to ask you to stop helping me.