RE: Auto inserting a database with dates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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/



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux