I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2009-10-30 13:33:55-07 by bruhnf
Help converting time array to epoch time
I am trying to convert a time array to epoch time. If I execute the following code with the time hard coded in the fields, I get the correct epoch time returned. Obviously, I had to subtract 1 for the month and 109 for the year (ie: 2009)
$epoch_time_var = timelocal(59,04,10,30,9,109); print "$epoch_time_var \n";
This prints 1256911934 (the correct epoch time that I hard coded in) but... If I try to use the elements of a time array to do the same thing, I get the error cannot handle date at line xxx.
my @time_array = localtime(time); $epoch_time_var = timelocal($time_array[0],$time_array[1],$time_array[2],$time_array[3],$time_array +[4]-1,$time_array[5]-1900); print "$epoch_time_var \n";
Any idea why this doesn't work and how to make it work? Thanks in advance for any help on this. Bruhn
Direct Responses: 11671 | Write a response