in reply to Re: Local Date Format
in thread Local Date Format
sub getdate{ my $ret = "$_[0]"; # Get the all the values for current time my ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOf +Year, $IsDST) = localtime(time); # In Perl, you'll need to increment the month by 1 my $RealMonth = $Month + 1; # Months of the year are not zero-base +d # Perl code will need to be adjusted for one-digit months if($RealMonth < 10) { $RealMonth = "0" . $RealMonth; # add a leading zero to one-digi +t months } # How to add a leading zero in Perl if($Day < 10) { $Day = "0" . $Day; # add a leading zero to one-digit days } # How to use modulo arithmetic in Perl if($Year >= 100) { $Fixed_Year = ($Year % 100); } else { $Fixed_Year = $Year; } # 1900 is subtracted from the value returned from localtime # Add it back in to get a 4-digit year $Year += 1900; # Format the string the way we want if ($ret == "1"){ $today = "$RealMonth\/$Day\/$Year"; return $today; } else{ $today = "$Year$RealMonth${Day}_$Hour${Minute}"; return $today; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Local Date Format
by gaal (Parson) on Feb 22, 2005 at 17:08 UTC | |
|
Re^3: Local Date Format
by meredith (Friar) on Feb 22, 2005 at 23:13 UTC |