Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Help with dates

by shockme (Chaplain)
on Nov 12, 2003 at 23:48 UTC ( #306675=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: Help with dates
Select or Download Code
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://306675]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-08-30 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (289 votes), past polls