When converting DMYHMS to Epoch Seconds and back I get cheated out of a day. 
Why?

Bill

--

#!/usr/bin/perl

use strict;
use warnings;
use Time::Local;

my ($time, $month, $day, $year, $seconds, $minutes, $hours, $wday, $yday, 
$isdst);

my $start_date = '11/30/2012';

print "$start_date \n";

($month, $day, $year) = split(/\//, $start_date);

print $time = timegm($seconds, $minutes, $hours, $day, $month-1, $year-1900);

print "\n";

($seconds, $minutes, $hours, $day, $month, $year, $wday, $yday, $isdst) = 
localtime($time);
    
$month++;

$year = ($year+1900);

print "$month/$day/$year \n";

# output:
# 11/30/2012 
# 1354233600
# 11/29/2012
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to