SPUG: Dates, anyone?

Steve Laybourn otter101 at hotmail.com
Thu Dec 30 17:01:51 CST 1999


Hello!

I'm just a bit late with this posting, which I found out went to the  wrong 
place the first time I posted it.

Here's a way I deal with changing a UNIX time into a valid time/date stamp:

@statz=stat("wossname.pl"); # or whatever file
$mz="Jan/Feb/Mar/Apr/May/Jun/Jul/Aug/Sep/Oct/Nov/Dec";
$wkd="Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday";
($sec,$min,$hour,$day,$nmon,$year,$wday,$yday,$isdst)=localtime($statz[9]);
if ($year<80) { $year+=2000; } else { $year+=1900; }
$wk=(split("/",$wkd))[$wday];
$mn=(split("/",$mz))[$nmon];
$lastmod=sprintf("%s, %s-%s-%s %02d:%02d:%02d 
PDT",$wk,$day,$mn,$year,$hour,$min,$sec);

This turns a large number of seconds into something like:

Thursday, 30-Dec-1999 14:59:43 PDT

I know this is probably not the best way to do this, but you don't have to 
refer to any external modules and you can customize the subroutine to output 
the date in any format you like...

Hope this helps!
Steve Laybourn

The answer to your question REALLY is: Five tons of flax!



______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address





More information about the spug-list mailing list