note 61439 deleted from function.mktime by nlopess

From: Date: Fri, 03 Feb 2006 20:41:07 +0000
Subject: note 61439 deleted from function.mktime by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-102945@lists.php.net to get a copy of this message
Note Submitter: Anderson Do Sitio ---- 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" );

« previous php.notes (#102945) next »