A simple example is calculating the number of days to borrow, which requires PHP to calculate on a daily basis, and here are a few ways to implement this date calculation:
(1) It's easy if you have a database! If MSSQL can use a trigger! Use a function DateDiff () that calculates the date difference.
If MySQL is the result of the calculation of the difference between the two date fields, the results are saved in another numeric field! Time to call!
(2) If you don't have a database, you have to use PHP's time-date function completely! The following are the main explanations:
Example: Calculate the number of days from May 3, 1998 to 1999-6-5:
$startdate =mktime ("0", "0", "0", "5", "3", "1998");
$enddate =mktime ("0", "0", "0", "6", "5", "1999");
The resulting value is the total number of seconds from 1970-1-1 to the parameter time: is an integer. So
The following code is so much more:
$days =round (($enddate-$startdate)/3600/24);
Echo $days;
Days for the day to get;
?>
If the parameter in Mktime () is the default, it means that the current date is used, so that the number of days from the borrowing date is calculated.
http://www.bkjia.com/PHPjc/321051.html www.bkjia.com true http://www.bkjia.com/PHPjc/321051.html techarticle A simple example is to calculate the number of days to borrow a book, which requires PHP based on the daily date of the calculation, the following talk about the implementation of this date calculation of several methods: (1) If there is a database ...