note 92351 added to function.date-parse

From: Date: Tue, 21 Jul 2009 08:14:45 +0000
Subject: note 92351 added to function.date-parse
Groups: php.notes 
Request: Send a blank email to php-notes+get-158528@lists.php.net to get a copy of this message
<?php // get difference of dates in days. function getDayDifference($start_date, $end_date) //YYYY-MM-DD, YYYY-MM-DD { $difference=0; if ($start_date<>'' && $end_date<>'') { $array_start = date_parse($start_date); $start_year = $array_start["year"]; $start_month = $array_start["month"]; $start_day = $array_start["day"]; $array_end = date_parse($end_date); $end_year = $array_end["year"]; $end_month = $array_end["month"]; $end_day = $array_end["day"]; $date_start=mktime(0,0,0,$start_month,$start_day,$start_year); $date_end=mktime(0,0,0,$end_month,$end_day,$end_year); $difference=$date_end-$date_start; $difference=floor($difference/(60*60*24));//Days. //$difference=floor($difference/(60*60*24*352));//Years. } return $difference; } ?> is there a batter way to do this???? ---- Server IP: 208.69.120.35 Probable Submitter: 124.29.215.187 ---- Manual Page -- http://www.php.net/manual/en/function.date-parse.php Edit -- https://master.php.net/note/edit/92351 Del: integrated -- https://master.php.net/note/delete/92351/integrated Del: useless -- https://master.php.net/note/delete/92351/useless Del: bad code -- https://master.php.net/note/delete/92351/bad+code Del: spam -- https://master.php.net/note/delete/92351/spam Del: non-english -- https://master.php.net/note/delete/92351/non-english Del: in docs -- https://master.php.net/note/delete/92351/in+docs Del: other reasons-- https://master.php.net/note/delete/92351 Reject -- https://master.php.net/note/reject/92351 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#158528) next »