Re: $mydata->StampDate

From: Date: Mon, 27 Jun 2005 04:47:45 +0000
Subject: Re: $mydata->StampDate
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-217674@lists.php.net to get a copy of this message
John Taylor-Johnston wrote: > I could just change the field type. But how do you calculate it? I don't > see much to inspire a start. I'm not a full-time coder either. More of a > tinkerer. I don't want someone to do it for me, but need to get my head > around how to do it. > http://ca3.php.net/manual/en/function.strtotime.php If you stick with a string data type, then I'd use the following to convert it to a UNIX timestamp (seconds since 1970-01-01) and find the number of days since 23 August 2003: $unix_timestamp = strtotime($mydata->StampDate); $timestamp_2003 = strtotime('2003-08-23'); $days_since_2003 = ($unix_timestamp - $timestamp_2003) / 60 / 60 / 24; $days_since_2003 now contains the number of days since 2003 for that date. You'd have to aggregate all your records to get the average hits per day. As I said, though, you should be using a MySQL date field. Have a look at the MySQL manual for the corresponding functions to the above -- there's probably a quicker way with MySQL too. Jasper

« previous php.general (#217674) next »