RE: [php-objects] newbie date question

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

 



>$fromDB_date = "2003-01-14";
>
>$date_array = explode("-", $fromDB_date);
>
>// add ten days to the day paramater
>$new_date = mktime(0,0,0,$date_array[1], $date_array[2]+10, $date_array[0]);

         Don't think this will work is date_array[2} + 10 is greater than 
the number
of days in the month.

         mktime() (check php.net) returns the time in seconds. There are 86,400
seconds in a day (60*60*24), therefor

$Timestamp = mktime(0,0,0,$ThisMonth,$ThisDOM,$ThisYear);
will return a Unix timestamp in seconds.
$Timestamp2 = $Timestamp + 86400 * 2 ;
returns a timestamp two days in the futures, Subtract to get previoud
days.

$Date = date("formatting",$Timestamp2);
will return a formatted day two days into the future. If can be formatted
any way you want, see http://php.net/date and http://php.net/mktime

         It can also be done with SQL statements, basically you create
a new field that is a result of a calculation and use the new field in
a calculation.

SELECT *, (TO_DAYS(CURRENT_DATE) - TO_DAYS(BillingDate)) as DaysOld
....
WHERE  DaysOld > 30 AND UnpaidBalance  > 0

Will select only those rows where there is an unpaid balance great than 30
days.

         To bring this back to PHP objects, I would suggest that you build a
class of date functions even though sever good ones exist. It will give you
practice with both the logic to solve the problem and building and using
object.

Urb



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Turn flat surfaces into speakers with the Soundbug.
http://us.click.yahoo.com/QWAVSC/onCFAA/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