RE: [PHP] Creating Dynamic Expiration Date
| From: | John Monfort | Date: | Tue, 06 Nov 2001 04:37:05 +0000 |
| Subject: | RE: [PHP] Creating Dynamic Expiration Date | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-73540@lists.php.net to get a copy of this message | ||
Also,
The problem is not as much with adding the months, as it is with getting
the current date.
date_add("12-05-10", interval 1 month) will work. This solution, however,
is limiting, since I will have to supply the date.
**remember, this is being done from the datebase. I need to get the date
via NOW(), CURDATE(), or CURRENT_DATE()**
hence, the need to use this format (or something similar):
date_add( current_date(), interval 12 months)
__________John Monfort_________________
_+-----------------------------------+_
P E P I E D E S I G N S
www.pepiedesigns.com
"The world is waiting, are you ready?"
-+___________________________________+-
On Mon, 5 Nov 2001, John Monfort wrote:
>
>
> That's a good way around it, and no, i have not.
>
> However, I did try to add 2 months...mysql seems to ignore the entire
> format. Instead, it adds 000000 in the field.
>
> btw, I trying to do this from the database side, not from the php script.
> I was hoping to using the function in the table field's DEFAULT
> parameter.
>
> I hope that trigger some new ideas.
>
> Thanks for the help.
>
> __________John Monfort_________________
> _+-----------------------------------+_
> P E P I E D E S I G N S
> www.pepiedesigns.com
> "The world is waiting, are you ready?"
> -+___________________________________+-
>
> On Mon, 5 Nov 2001, Jack Dempsey wrote:
>
> > have you tried 12 months instead of 1 year?
> >
> > -----Original Message-----
> > From: John Monfort [mailto:monfort@kahuna.sdsu.edu]
> > Sent: Monday, November 05, 2001 10:49 PM
> > To: php-general@lists.php.net
> > Subject: [PHP] Creating Dynamic Expiration Date
> >
> >
> >
> > Hello everyone,
> >
> > I'm developing a database which holds a START and EXPIRATION date.
> > I would like to have MySQL generate the expiration date automatically and
> > was wondering if that could be done.
> >
> > I'm using the MySQL NOW() to add today's date as the START date.
> > The expiration date is one year from the start date. I read about the
> > mysql DATE_ADD function, in which can be used as
> >
> > DATE_ADD("2001-11-05 13:00:00", INTERVAL 2 MONTHS)
> >
> > Is there a way to use it as DATE_ADD( NOW(), INTERVAL 1 YEAR), to
> > automatically add one year to today's date.
> >
> > I tried the above, but it did not work. The start and expiration date
> > still come out as the current date( the result of NOW() ).
> >
> > btw, both START and EXPIRATION are of the data type TIMESTAMP (8).
> >
> > Please help.
> >
> > How do I (dynamically) add one year to the current date?
> >
> > i.e. add_date(CURDATE(), INTERVAL 1 YEAR)
> >
> >
> > -john
> >
> > __________John Monfort_________________
> > _+-----------------------------------+_
> > P E P I E D E S I G N S
> > www.pepiedesigns.com
> > "The world is waiting, are you ready?"
> > -+___________________________________+-
> >
> >
> >
> > --
> > 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
>