"John W. Krahn" wrote:
> 
> John Dunn wrote:
> >
> > I need to return the current date and time in the following format
> >
> > YYYYMMDDHHMMSS
> >
> > but am struggling to do this using the localtime function
> >
> > In perticular, how do I get the month number(e.g. 09 for Sep)?
> 
> my ( $year, $mon, @time ) = reverse (localtime)[0..5];

Sorry, that should be:

my ( $year, $mon, @time ) = reverse( (localtime)[0..5] );

> my $date = sprintf '%04d%02d%02d%02d%02d%02d', $year+1900, $mon+1, @time;
> 
> # OR
> 
> use POSIX qw(strftime);
> my $date = strftime '%Y%m%d%H%M%S', localtime;


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to