| To achieve a calculation of the time difference in the code, the number of days, I remember in other programs to see the conversion into years and days, so began to write a bit, in fact, is very simple, is a few conversion, But in the monthly statistics is not very accurate, because the month, do not know how many days to calculate, so I replaced the month 30 days conversion, the error should not be small, this is impossible to solve. Example, the code for calculating the station time: $jztime station time format: 2013-01-01
-
- !--? php $days = ABS (Strtotime ($jztim e)-Strtotime (Date ("y-m-d")))/86400;
- if ($days >365) {
- $site _y=intval ($days/365). " Year-";
- }
- if ($days >31) {
- $str =explode (".", $days/365);//obtain data for the remainder of the year
- $site _m = ("0.". $str [(Count ($STR)-1)] *365/30;
- $site _m = intval ($site _m). " Month-";
- } bbs.it-home.org
- if ($days >1) {
- $str =explode (".", $days/365);//continue to get the rest of the data
- $site _d = ("0."). $str [(Count ($STR)-1)]) *365-(intval ($site _m) *30);
- $site _d = intval ($site _d). " Days ";
- }
- $dayst = $site _y. $site _m. $site _d;
- echo $dayst;
- ?
copy code |