What do you mean, 'one of the variables keeps producing an error'? Which variable, what error?
Are you using use warnings; and use strict;?
What are the contents of $sec, $min, $hhour, $day, $month, and $year just prior to the timelocal call? (just for an example of data that produces the error)