Re: Statistical data handling in php
| From: | O. | Date: | Tue, 25 Jul 2000 14:10:50 +0000 |
| Subject: | Re: Statistical data handling in php | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8044@lists.php.net to get a copy of this message | ||
"Christopher Ditty" <CDitty@email.usps.gov> wrote in message
news:0033000001318359000002L092*@MHS...
Does anyone here do any statistical data handling in php?
ie....finding average number of user by the hour, day, week, month,
year? How do you do the date ranges? I am just getting into the week
sections and the only way I can figure it out is to use 7 if
statements for each week. (see
below) It makes for some REALLY ugly code. Any pointers?
I have a table named traffic_global in my mySQL database in which I store
among other things, a date time field. DateTime is useful in that it stores
data in a way that makes comparison easy, as well as things like what you're
trying to do. If you're not using a database, use strtotime to convert your
English dates to ctime, then calculate the week ranges using seconds ...
requires a bit of math, but it makes things vastly easier if you're not
using a database like mySQL.
For example ...
A day has 86400 seconds, a week has 7 * that ... add that to the beginning
of the week (ie, Jul 23, 2000 12:00 AM) in ctime, you have two integers
which all dates for a given week must fall between.
--
O.