in reply to Time local

The format for $app_date that you give appears to be month-day-year (or day-month-year—I can't tell which), but your code thinks it's year-month-day. I think your second line down should be:

($amonth,$aday,$ayear) = split(/-/, $adate);

Pulling those fields out of your input might be a little more readable with regular expressions. You could replace all of your split lines with this (unless you need $adate or $atime later):

( $amonth, $aday, $ayear, $ahour, $amin, $asec ) = ( $app_date =~ /^(\d\d?)-(\d\d?)-(\d{4}) (1?\d):(\d\d):(\d\d)/ ) +;

Or this, if you're into xms regexes:

( $amonth, $aday, $ayear, $ahour, $amin, $asec ) = ( $app_date =~ m{ \A # beginning of string (\d\d?)-(\d\d?)-(\d{4}) # month-day-year \s # space separator (1?\d):(\d\d):(\d\d) # hour:minutes:seconds }xms );

Replies are listed 'Best First'.
Re^2: Time local
by Anonymous Monk on Dec 21, 2006 at 18:26 UTC
    I put some debug strings and the date appears as follows: adate is 2007-01-01, atime is 12:00:00 , i had the wrong format before... I will try out the above. Is the --$month right to use?
      I'd use $month-1, since there's no reason to modify $month in the process. The subtraction is required since timelocal expects a 0-based month (Jan = 0).