Databases Reference
In-Depth Information
TimeDifference($Time, $seconds, $hours, $minutes, $days);
echo "\n".sprintf("%3d days, %2d hours, %2d minutes, and %2d seconds",
$days, $hours, $minutes, $seconds);
echo " since you left ... :(";
$Time="2006-11-15 20:00:00";
TimeDifference($Time, $seconds, $hours, $minutes, $days);
echo "\n".sprintf("%3d days, %2d hours, %2d minutes, and %2d seconds",
$days, $hours, $minutes, $seconds);
echo " till I see you again... :)";
echo "\n";
function TimeDifference($ReferenceTime, &$seconds, &$hours, &$minutes, &$days)
{
$seconds=abs(strtotime($ReferenceTime) - mktime());
$days =intval(($seconds) /( 24*60*60));
$hours =intval(($seconds-($days*24*60*60)) /( 60*60));
$minutes=intval(($seconds-($days*24*60*60)-($hours*60*60)) /( 60));
$seconds=intval(($seconds-($days*24*60*60)-($hours*60*60)-($minutes*60)));
}
?>
You should use the PHP manual at http://www.php.net/manual/ to look up infor-
mation on new functions. To get you started, here are some short explanations:
abs( )
Returns the absolute value of a number passed to it (it removes the minus sign
for negative numbers).
intval( )
Converts a floating number into an integer.
mktime( )
Returns the current time in the Unix timestamp format.
sprintf( )
Creates a string from the values passed to it using the format specifiers.
strtotime( )
Converts a string into the Unix timestamp format.
What does the line at the top of the file indicate? What would happen if you tried
to run this program from a web server?
 
Search WWH ::




Custom Search