note 98143 added to function.date-diff
| From: | djmib at djmib dot net | Date: | Fri, 28 May 2010 01:58:54 +0000 |
| Subject: | note 98143 added to function.date-diff | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-169677@lists.php.net to get a copy of this message | ||
Other Example:
PS:
$strTipo = Type of return (s= second | m= minute | h= hour | D= days).
$strDataIni = Start Date of interval.
$strDataFim = End Date of interval.
The date is in format yyyymmdd -> 99991231 or text "now" to indicate now.
function dataDiferenca($strTipo, $strDataIni, $strDataFim){
if($strDataIni!="now"){
if(!checkdate( substr($strDataIni,4,2), substr($strDataIni,6,2), substr($strDataIni,0,4))){
return false;
}
}
if($strDataFim!="now"){
if(!checkdate( substr($strDataFim,4,2), substr($strDataFim,6,2), substr($strDataFim,0,4))){
return false;
}
}
$data = date("U",strtotime($strDataFim)) - date("U",strtotime($strDataIni));
if($strDataIni=="now"&&$strDataFim!="now"&&date("I")){
$data += 3600;
}else
if($strDataIni!="now"&&$strDataFim=="now"&&date("I")){
$data -= 3600;
}
$arrData = array(
"s" => $data,
"m" => floor($data / 60),
"h" => floor($data / 60 / 60),
"D" => floor($data / 60 / 60 / 24)
);
return (is_null($arrData[$strTipo]))?0:$arrData[$strTipo];
}
----
Server IP: 69.147.83.197
Probable Submitter: 187.126.19.68
----
Manual Page -- http://www.php.net/manual/en/function.date-diff.php
Edit -- https://master.php.net/note/edit/98143
Del: integrated -- https://master.php.net/note/delete/98143/integrated
Del: useless -- https://master.php.net/note/delete/98143/useless
Del: bad code -- https://master.php.net/note/delete/98143/bad+code
Del: spam -- https://master.php.net/note/delete/98143/spam
Del: non-english -- https://master.php.net/note/delete/98143/non-english
Del: in docs -- https://master.php.net/note/delete/98143/in+docs
Del: other reasons-- https://master.php.net/note/delete/98143
Reject -- https://master.php.net/note/reject/98143
Search -- https://master.php.net/manage/user-notes.php