Let me qualify this answer by saying I don't really use Time::Piece. I just downloaded, compiled, and installed it. The difference I was getting was a bit larger than yours... I was getting an 8 hour difference. Coincidentally, that's my offset from GMT. I made sure my TZ environment variable was set correctly and changed the assignment to $now to this:
And that seemed to do the trick. You might try the same change and find that it magically works.$now = locatime() + $before->tzoffset;
By the way, you have a couple other little errors, I think. You subtract $hours * ONE_HOUR before you determine $hours and you neglect to subtract $days * ONE_DAY. You also add an 'S' on to the constant for ONE_MINUTE. And there doesn't appear to be a constant for ONE_SECOND, which only makes sense if you think about it. It just so happens that none of these would have affected your testing so far.
-sauoq "My two cents aren't worth a dime.";
In reply to Re: More Help please ? Time::Piece errors?
by sauoq
in thread Time::Piece errors?
by spacey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |