P
Paul E. Schoen
I have been trying to get the number of days from 2010-09-13 to today, and
I'm getting strange results. I have consulted the FAQ and the Date::Calc
qw(Delta_Days) and Time::localtime modules, as well as
http://docstore.mik.ua/orelly/perl/cookbook/ch03_04.htm and
http://docstore.mik.ua/orelly/perl/cookbook/ch03_06.htm.
Here is the pertinent code:
#!/usr/bin/perl
use Date::Calc qw(Delta_Days);
use Time::localtime;
my $tm = localtime($time);
my $yr = $tm->year+1900;
my $mo = $tm->mon+1;
my $dy = $tm->mday;
my @dtStart = (2010, 9, 13);
my @dtNow = ($yr, $mo, $dy);
my $difference = Delta_Days(@dtStart, @dtNow);
my $hitRate = $count/$difference; #count is number of hits
print "Content-type: text/html\n\n";
print "Visitors in $difference days since Sept 13, 2010:
$count or $hitRate per day $yr, $mo, $dy";
The text in the website that uses this reads:
Visitors in -14866 days since Sept 13, 2010: 00359 or
-0.0241490649804924 per day 1969, 12, 31
I've tried so many different things that I'm totally confused. There seem to
be many ways to do this and it should be a simple task.
TIA,
Paul
I'm getting strange results. I have consulted the FAQ and the Date::Calc
qw(Delta_Days) and Time::localtime modules, as well as
http://docstore.mik.ua/orelly/perl/cookbook/ch03_04.htm and
http://docstore.mik.ua/orelly/perl/cookbook/ch03_06.htm.
Here is the pertinent code:
#!/usr/bin/perl
use Date::Calc qw(Delta_Days);
use Time::localtime;
my $tm = localtime($time);
my $yr = $tm->year+1900;
my $mo = $tm->mon+1;
my $dy = $tm->mday;
my @dtStart = (2010, 9, 13);
my @dtNow = ($yr, $mo, $dy);
my $difference = Delta_Days(@dtStart, @dtNow);
my $hitRate = $count/$difference; #count is number of hits
print "Content-type: text/html\n\n";
print "Visitors in $difference days since Sept 13, 2010:
$count or $hitRate per day $yr, $mo, $dy";
The text in the website that uses this reads:
Visitors in -14866 days since Sept 13, 2010: 00359 or
-0.0241490649804924 per day 1969, 12, 31
I've tried so many different things that I'm totally confused. There seem to
be many ways to do this and it should be a simple task.
TIA,
Paul