RE: [PHP] Incrementing dates

From: Date: Sun, 22 Apr 2001 14:28:32 +0000
Subject: RE: [PHP] Incrementing dates
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-49747@lists.php.net to get a copy of this message
If you are looking for a PHP only solution you might try hand calculating the amount of time you want to adjust in seconds (i.e. 60 seconds x 60 minutes x 24 hours x 10 days = 864000) $newdatetime = (strtotime($otherdatetime) + 864000; I often use something similar to adjust for timezone differences. There are lots of other datetime functions in the manual ;) Warren Vail -----Original Message----- From: PHPBeginner.com [mailto:php-general@phpbeginner.com] Sent: Sunday, April 22, 2001 3:09 AM To: Martin Skjoldebrand; php-general@lists.php.net Subject: RE: [PHP] Incrementing dates you can then do this: INSERT INTO table SELECT date+INTERVAL 10 DAYS AS date FROM table WHERE bla=bla; it is just a way to do it. you will definitely have to play with it. However you can easily make two queries to read the previous date combining it with INTERVAL and then do an insert. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com -----Original Message----- From: Martin Skjoldebrand [mailto:chimbis@skjoldebrand.org] Sent: Sunday, April 22, 2001 5:59 PM To: php-general@lists.php.net Subject: RE: [PHP] Incrementing dates PHPBeginner.com wrote: > I am not sure on how your possibilities are, > but doing this in PHP means literally "adding useless lines and loops" > > If possible, do it with SQL queries. Read the documentations on date > datatypes, this is so much easier... almost magic. > AND > You can (mySQL, right?) do the following: >UPDATE table SET date=(date+INTERVAL 10 DAYS); >so if date there was 04-28, it will be added 10 more days and so will >become >05-08 >Use SQL for this things, it treats dates as 'dates' while PHP treats them >as >integers and strings. Sounds even easier. But what if I'm not doing an UPDATE but an INSERT? Can it read the previous date? I am inserting a batch of bookings at one time. Martin S. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#49747) next »