RE: [PHP] Date/Time Arithmetic
>Is it possible to do some arithmetic with time/date values in PHP? > for example, to calculate: >today + 1050 days. >today - 7 days. >etc. > I mean, does PHP have functions to perform these operations? $oneDay = 86400; // number of seconds in a day // 60 seconds * 60 minutes * 24 hours $today = date( "U" ); // lookup the date() function $oneWeekAgo = $today - ( $oneDay * 7 ); $1050Days = $today + ( $oneDay * 1050 ); echo "The date for one week ago is: "; echo date( "F d, Y", $oneWeekAgo ); echo "1,050 days in the future is: "; echo date( "F d, Y", $1050Days ); The unix timestamp is an awesome tool for date arithmetic. Time arithmetic uses the same logic but on a smaller scale. $oneMinute = 60; // seconds $oneHour = 3600; // seconds; 60 seconds * 60 minutes Chris
[PHP] Date/Time Arithmetic
Hello, Is it possible to do some arithmetic with time/date values in PHP? for example, to calculate: today + 1050 days. today - 7 days. etc. I mean, does PHP have functions to perform these operations? Thanks, Erich Reimberg. PS. I'm new to PHP, and I didn't find anything like this in the FAQ Please Cc to my email: [EMAIL PROTECTED], for there are many posts in this group that my server seems to loose. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]