|
Posted by NC on 09/21/05 02:27
bigfella wrote:
>
> In MYSQL would like to produce a field for 3,6,9 or 12 months just
> containing the dates of every 7 days from the current date.
$months = 3; // or 6, or 9, or 12
$now = time();
$day = $now + 7*24*60*60;
$cutoff = strtotime("+$months months");
while ($day <= $cutoff) {
$date = date('Y-m-d', $day);
$insert = "INSERT INTO the_table SET date='$date'";
mysql_query($insert);
$day = $day + 7*24*60*60;
}
Cheers,
NC
[Back to original message]
|