"Gregg O'Donnell" <[EMAIL PROTECTED]> writes:
>
>
> I'm looking for the simplest way to use the date and time in the format of
>MMDDYYHHmm (no spaces), which is used later in the program.
>
> Here's what I've come up with; comments or suggestions are appreciated.
>
> #Insert Date and Time
> my $month = $mon00 #Two digit month
> my $day = $mday00 #Two digit day in month
> my $year = $year #Two digit year
> my $hour = $hour00 #Two digit: Hour
> my $min = $min00 #Two digit: Minutes
> #Combine date and time above into MMDDYYHHmm format
> my @log_date = qw($month$day$year$hour$min)
That depends on what format you start with...
Short version:
'
#!/usr/bin/perl -wl
use strict;
use POSIX;
my @time = localtime(time);
print POSIX::strftime("%m%d%y%H%M",@time);
'
time is 'unixtime'. localtime in array context returns a 'time
array', whose format you can read about in the docs.
strftime uses an ansi c standard time format string - there are
several places you can look up the possible arguments.
-RN
--
Robin Norwood
Red Hat, Inc.
"The Sage does nothing, yet nothing remains undone."
-Lao Tzu, Te Tao Ching
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]