John Dunn wrote:
> I need to return the current date and time in the following format
>
> MMDDHHMMSS
>
> but am struggling to do this using the localtime function
Use the POSIX strftime() function:
use POSIX 'strftime';
print strftime("%Y%m%d%H%M%S", localtime);
This works on both
"John W. Krahn" wrote:
>
> John Dunn wrote:
> >
> > I need to return the current date and time in the following format
> >
> > MMDDHHMMSS
> >
> > 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, $m
John Dunn wrote:
>
> I need to return the current date and time in the following format
>
> MMDDHHMMSS
>
> 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];
my
Probably not the prettiest, but it should work...
my ($sec,$min,$hour,$mday,$mon,$year) = (localtime(time))[0..5];
my $date =
sprintf("%04d",$year+1900) .
sprintf("%02d",$mon+1) .
sprintf("%02d",$mday) .
sprintf("%02d",$hour) .
sprintf("%02d",$min) .
is a strftime()
function that is similar to 'date' for UNIX, but I haven't used it.
-Original Message-
From: Dan Muey
To: John Dunn; [EMAIL PROTECTED]
Sent: 1/6/03 7:10 AM
Subject: RE: return date/time in required format
Print `date +%m`;
Prints '01' for january,
Print `date +%m`;
Prints '01' for january, '02' for February etc
You can format all kinds of time with this.
Unix> man date
Dan
-Original Message-
From: John Dunn [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 06, 2003 8:58 AM
To: [EMAIL PROTECTED]
Subje
I need to return the current date and time in the following format
MMDDHHMMSS
but am struggling to do this using the localtime function
In perticular, how do I get the month number(e.g. 09 for Sep)?
John Dunn
Sefas Innovation Ltd
0117 9154267
www.sefas.com
--
To unsubscribe, e-mail: [EMA