Reply to Re: Dates between Mysql and PHP

Your name:

Reply:


Posted by NC on 04/12/06 19:14

Martin Wright wrote:
>
> I hope someone can help or point me in the right direction. I am new to PHP
> and I am trying to pick up a DATE type field in a mysql_query Select
> statement, bring it into php add a number of days to this date and inert a
> new record with the new date.
>
> The item that appears to be assigned to the php variable appears to be a
> string 2006-04-11.

But of course it is. Here's what you need to do:

$old_date = '2006-04-11';
$days_to_add = 3;
$new_date = date('Y-m-d', strtotime($old_date) + $days_to_add * 60 * 60
* 24);

Now $new_date is ready for insertion.

Cheers,
NC

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация