How many days does PHP calculate to a specified date
This example describes how PHP calculates the number of days to a specified date. Share to everyone for your reference. Specific as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21st 22 23 24 |
function Countdays ($d) { $olddate = substr ($d, 4); $newdate = Date (Y). "". $olddate; $nextyear = Date (Y) +1. "". $olddate; if ($newdate > Date ("y-m-d")) { $start _ts = Strtotime ($newdate); $end _ts = strtotime (Date ("y-m-d")); $diff = $end _ts-$start _ts; $n = Round ($diff/86400); $return = substr ($n, 1); return $return; } Else { $start _ts = Strtotime ($nextyear); $end _ts = strtotime (Date ("y-m-d")); $diff = $end _ts-$start _ts; $n = Round ($diff/86400); $return = substr ($n, 1); return $return; } } |
http://www.bkjia.com/PHPjc/983325.html www.bkjia.com true http://www.bkjia.com/PHPjc/983325.html techarticle How many days does PHP calculate to a specified date? This example describes how PHP calculates the number of days to a specified date. Share to everyone for your reference. as follows: 1 2 3 4 5 ...