|
Posted by Ben Morrow on May 4, 2008, 2:29 pm
Please log in for more thread options
> > I want to print the current time(stamp) in formatted style.
> > The following does not work:
> >
> > print STDOUT "Now=%Y%m%d-%H%M\n", localtime(time);
>
<snip>
> If you want to use a print-equivalent statement to do your formatting,
> you need to use printf. Also, perl date formatting has nothing to do
> with UNIX date; %Y for example is the hash named Y, and bears no
> relation at all to your call to localtime. Read perldoc -f sprintf for
> valid formats (%Y is certainly not one).
...however it is a valid format for strftime, which I suspect is what
the OP wanted.
use POSIX qw/strftime/;
print STDOUT strftime "Now=%Y%m%d-%H%M\n", localtime;
Ben
--
I have two words that are going to make all your troubles go away.
"Miniature". "Golf".
[ben@morrow.me.uk]
|