Any PERL programmers ?

Lazarus

Part of the furniture
Joined
Dec 22, 2003
Messages
2,874
Guys,

trying to do something very simple with PERL, but Im no perl programmer.

Other languages are NOT an option.

I have calculated the date/time :

Code:
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time) ; 
my $RealMonth = $Month + 1 ; # Months of the year are not zero-based 
if($RealMonth < 10) 
{ 
$RealMonth = "0" . $RealMonth ;
}
if($Day < 10) 
{ 
$Day = "0" . $Day ; # add a leading zero to one-digit days 
} 
$Fixed_Year = $Year + 1900; 
$Year += 1900 ;

which results in the value (example) 20050517112345

I want to be able to format this to something like :

2005/05/14-11:23:45

that bit is easy using

printf("%04d/%02d/%02d%02d:%02d:%02d", $Year, $RealMonth, $Day, $Hour, $Minute, $Second)

but what I REALLY want to do is set a variable to the formatted value for the date

i.e. $today="formatted date and time"

any clues?
 

Lazarus

Part of the furniture
Joined
Dec 22, 2003
Messages
2,874
with the help of my newly acquired, learned friend, i got it working.

Many thanks BinGOs
 

Users who are viewing this thread

Top Bottom