in reply to Converting dates
So first you must get your year/month/day out of the string:
Subtract 1 from the month, as January is month 0. Seconds since the epoch can be found like this:$date = '05-02-2003'; my($d,$m,$y) = $date =~ /(\d+)-(\d+)-(\d+)/;
I use midnight, and GMT, as a reference, with regards to summer time issues — GMT doesn't have them. If you desire finer results, with an exact hours/minutes/seconds count, you can always use timelocal(), and real times.use Time::Local; my $time = timegm(0, 0, 0, $d, $m-1, $y);
The calculated value is 1044403200. You can see that it works well, like this:
which producesprint scalar gmtime($time);
OK?Wed Feb 5 00:00:00 2003
|
|---|