Problem with timegm function in perl

Hello..

In my code i use the following function:

$epochTime = timegm($sec, $min, $hour, $day, $month, $year)

The problem is that when $day==31, i get the following error:

Day '31' out of range 1..30 at unrated_namp_program line 113

Any idea how to overcome this???

Thank you very much

What is the value of $month?

The value of the month is $month=05
the whole string is like:
20080531142034

I believe month is 0-11, not 1-12. So 05 is June which has 30 days.

Also - assume the $year value is 2008. You have to subtract 1900 from that value first - ie., $year-=1900 or 108 in this case.

timegm will try to report a few extra days or hours, ie., March 32, 2008, but bad dates have the potential for bad results, so watch it. timegm is not that robust. It may create a completely bogus result.

Thats correct. The months are numbered 0-11 so the code has to stick with that convention.