RE: [PHP-DB] Auto inserting a database with dates

From: Date: Sun, 02 Mar 2003 16:40:04 +0000
Subject: RE: [PHP-DB] Auto inserting a database with dates
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-26051@lists.php.net to get a copy of this message
> Is there a quick and easy (HAH :-) way of doing the following: > > I have a DB and a table with id, date etc ..... now what I need is to > create 3 years of entries for the date in advance of the system going live > (Rather than while they use it - hard to explain why but necessary). > > Is there an easy way to write a short PHP script that will populate the > field $stock with 3 years dates in advance from the current date, using > the format 02-03-200x ? it's either this way or I go through and insert > new onces argghhh (That's not a pleasant thought :-) This will print out the dates for you. Adapt accordingly to insert into your database.... can't shake this bad feeling that you're doing something the hard way, though... <?php $end = 365 * 3; for($x=0;$x<$end;$x++) { $date = date('d-m-Y',strtotime("today + $x days")); echo $date . "<br>\n"; } ?> ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.db (#26051) next »