note 115065 added to function.date-diff

From: Date: Wed, 21 May 2014 08:07:39 +0000
Subject: note 115065 added to function.date-diff
Groups: php.notes 
Request: Send a blank email to php-notes+get-199584@lists.php.net to get a copy of this message
Powerful Function to get two date difference. ////////////////////////////////////////////////////////////////////// //PARA: Date Should In YYYY-MM-DD Format //RESULT FORMAT: // '%y Year %m Month %d Day %h Hours %i Minute %s Seconds' => 1 Year 3 Month 14 Day 11 Hours 49 Minute 36 Seconds // '%y Year %m Month %d Day' => 1 Year 3 Month 14 Days // '%m Month %d Day' => 3 Month 14 Day // '%d Day %h Hours' => 14 Day 11 Hours // '%d Day' => 14 Days // '%h Hours %i Minute %s Seconds' => 11 Hours 49 Minute 36 Seconds // '%i Minute %s Seconds' => 49 Minute 36 Seconds // '%h Hours => 11 Hours // '%a Days => 468 Days ////////////////////////////////////////////////////////////////////// function dateDifference($date_1 , $date_2 , $differenceFormat = '%a' ) { $datetime1 = date_create($date_1); $datetime2 = date_create($date_2); $interval = date_diff($datetime1, $datetime2); return $interval->format($differenceFormat); } ---- Server IP: 72.52.91.14 Probable Submitter: 117.212.189.149 ---- Manual Page -- http://php.net/manual/en/function.date-diff.php Edit -- https://master.php.net/note/edit/115065 Del: integrated -- https://master.php.net/note/delete/115065/integrated Del: useless -- https://master.php.net/note/delete/115065/useless Del: bad code -- https://master.php.net/note/delete/115065/bad+code Del: spam -- https://master.php.net/note/delete/115065/spam Del: non-english -- https://master.php.net/note/delete/115065/non-english Del: in docs -- https://master.php.net/note/delete/115065/in+docs Del: other reasons-- https://master.php.net/note/delete/115065 Reject -- https://master.php.net/note/reject/115065 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#199584) next »