in reply to displaying the current date

The POSIX module also provides the strftime() function, which is very convenient to use in this case as well:

use strict; use POSIX qw(strftime); sub local_yyyymmdd { my ($time) = shift || time; return strftime( '%Y-%m-%d', localtime($time)); };

Documentation on strftime is pretty scarce, as it is the C function of the same name, but the DateTime module has a similar function which takes similar parameters in the format string.

Updated: Added dashes thanks to ysth, added paragraph about the documentation

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

Replies are listed 'Best First'.
Re: Re: displaying the current date
by duff (Parson) on Dec 08, 2003 at 15:20 UTC

    DateTime also has a routine ymd that outputs the date in exactly the format he needs :-)