Get the time stamp for this week, the first day of the month, and the last day with PHP.
1, get today's time range:
2, get the timestamp of the first day/last day of the week
<?php$year = Date ("Y"), $month = Date ("M"), $day = Date (' W '), $nowMonthDay = Date ("T"), $firstday = Date (' d ')-$day; if (sub STR ($firstday, 0,1) = = "-") {$firstMonth = $month-1; $lastMonthDay = date ("T", $firstMonth); $firstday = $lastMonthDay-S Ubstr ($firstday, 1); $time _1 = Strtotime ($year. " -". $firstMonth." -". $firstday);} else{$time _1 = Strtotime ($year. " -". $month." -". $firstday);} $lastday = Date (' d ') + (7-$day), if ($lastday > $nowMonthDay) {$lastday = $lastday-$nowMonthDay; $lastMonth = $month + 1; $time _2 = Strtotime ($year. " -". $lastMonth." -". $lastday);} else{$time _2 = Strtotime ($year. " -". $month." -". $lastday);}
3, get the time stamp of the first day/last day of this month
<?php$year = Date ("Y"), $month = Date ("M"), $allday = Date ("T"), $strat _time = Strtotime ($year. " -". $month." -1 "); $end _time = Strtotime ($year." -". $month." -". $allday);
Calculate Time Difference
$one = Strtotime (' 2011-12-08 07:02:40 ');//Start time timestamp
$tow = Strtotime (' 2011-12-25 00:00:00 ');//End time Timestamp
$cle = $tow-$one; The time stamp difference value is obtained
$d = Floor ($cle/3600/24);
$h = Floor (($cle% (3600*24))/3600); % take-up
$m = Floor (($cle% (3600*24)) 600/60);
$s = floor (($cle% (3600*24));
echo "Two time difference $d days $h hours $m minutes $s seconds"
PHP gets time to calculate the difference