note 61441 deleted from function.mktime by nlopess
| From: | nlopess@php.net | Date: | Fri, 03 Feb 2006 20:41:19 +0000 |
| Subject: | note 61441 deleted from function.mktime by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-102947@lists.php.net to get a copy of this message | ||
Note Submitter: Anderson Do Sitio
----
<?php
function calcular_horas( $hr1, $op, $hr2 )
{
if(
(!preg_match( '/([0-9]{2}):([0-9]{2}):([0-9]{2})/', $hr1 )) ||
(!preg_match( '/([0-9]{2}):([0-9]{2}):([0-9]{2})/', $hr2 )) ||
( ($op != '-') && ($op != '+') )
)
return false;
list( $h1, $m1, $s1 ) = explode( ':', $hr1 );
list( $h2, $m2, $s2 ) = explode( ':', $hr2 );
eval( "\$d = date(\"H:i:s\", mktime( date( \"$h1\" ) $op $h2, date(
\"$m1\" ) $op $m2,
date( \"$s1\" ) $op $s2, date(\"m\"), date(\"d\"),
date(\"Y\") ) );" );
return $d;
}
echo calcular_horas( "13:25:42", "-", "03:00:00" );
echo calcular_horas( "08:36:54", "+", "06:25:36" );
?>