Re: [php-objects] newbie date question

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

 



This is not really a OOP in PHP type of question [grin].

A quick look at the MySQL manual would've answer your questions faster than
anyone could:

http://www.mysql.com/doc/en/Date_and_time_functions.html

http://www.mysql.com/doc/en/Date_calculations.html

For (1), you could use DATE_FORMAT(). If you are going to do date math, and
prefer to use PHP for that, use UNIX_TIME() in your MySQL query, then
add/substract the appropriate number of seconds and use date() to format the
output. Or, you can get the MySQL date in the YYYY-MM-DD format, parse it
(using your favorite method: explode(), substr(), regex, etc.), then combine
that w/ mktime() and date().

For (2) see the notes to the manual page about date calculation mentioned
above.

Happy reading.

--- Steve Miller <steve@dinnys.com> wrote:
> I am inserting dates into mysql using the curdate() function, which is
> generating a date in 2003-01-13 format. I need to do 2 things:
> 
> 1. be able to retrieve the date, add days to it, and display the new future
> date in January 13, 2003 format, and
> 
> 2. be able retrieve records where the inserted date is within a range a days
> passed
> 
> I have been able to do what I want for part 2 by using the to_days function,
> but I am having trouble trying to to part one. Can someone help with the
> first part, or suggest a better way to go?
> 
> Many Thanks,
> steve miller 

=====
--- Jesus M. Castagnetto (jcastagnetto@yahoo.com)

Research:
 http://metallo.scripps.edu/
Personal: http://www.castagnetto.org/

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Flexible Keyboard is the ideal accessory for PDA users that are on the move.
http://us.click.yahoo.com/dCBVZC/WnCFAA/xGHJAA/saFolB/TM
---------------------------------------------------------------------~->

Look here for Free PHP Classes of objects:
http://phpclasses.UpperDesign.com/
To unsubscribe from this group, send an email to:
php-objects-unsubscribe@egroups.com

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux