Problems? Is your data what you think it is? | |
PerlMonks |
Re: Number of days sinceby FreeBeerReekingMonk (Deacon) |
on Jul 14, 2016 at 15:35 UTC ( [id://1167788]=note: print w/replies, xml ) | Need Help?? |
Well, there are many libraries that do that, so read up on those from fellow monks.
The reason for that is that there are extra seconds, so some days exist that have 23:59:62 as a real, existing time. Then, you have a difference between localtime and UTC time. If you do not care much about that precision, and assume localtime, then you can use timelocal to transform the start and end dates into an epoch (seconds sinds 1970-01-01), substract these two numbers, and divide this number /60/60/24 to get aproximate days, then maybe round the value. Here is an example:
Instead of the secToTimeString0() function, you can also use round to get an integer number of days, like so:
In Section
Seekers of Perl Wisdom
|
|