Quote:
Originally Posted by Velocd
Timestamps are in seconds. They're much more convenient to use, from my experience, then the inflexible SQL date format. Plus, they contain time, not merely the date.
So if you want days, take (60 x 60) x 24, giving you 86,400. 86,400 x 2, 3, ... 7 will give you those timestamps for that duration of days.
PHP Code:
// Place ranges into an array.
for ($i = 1; $i <= 7; $i++)
{
$array[] = TIMENOW - ($i * 86400);
}
Another method to get the timestamp (relative to today) without math is using strtotime():
PHP Code:
$seven_days_ago = strtotime('7 days ago');
|
That can't work because days start and end at midnight, and the functions you cite calculate going back from the current time.
I found something that I *think* will work, the MySQL UNIX_TIMESTAMP function...