note 98143 added to function.date-diff

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.