in reply to Subroutine for returning a date, similar to sprintf

You can get much of the same functionality by using POSIX.pm's strftime function.

use POSIX qw/strftime/; sub days { return $_[0] * 86400 } print strftime( "%d-%m-%Y,%H:%M:%S\n", localtime ); print strftime( "%d-%m-%Y,%H:%M:%S\n", localtime(time - days( 22))); print strftime( "%d-%m-%Y,%H:%M:%S\n", localtime(time + days(180))); print strftime( "time: %H:%M date: %d/%m/%Y\n", localtime ); print strftime( "%d%m%y\n", localtime ); print strftime( "%S seconds\n", localtime ); print int( strftime( "%S", localtime ) ), " seconds\n";

    --k.


Replies are listed 'Best First'.
Re: Re: Subroutine for returning a date, similar to sprintf
by leons (Pilgrim) on May 28, 2001 at 18:22 UTC
    Ahem,

    Thanks ... this would have saved me quite some time ...
    ... Oh well ... I finally got to use 'eval' ... now that's
    worth something ;-)

    Bye, Leon