<?php
require_once 'timeS2timeF.php';
$arr = [
12,
12.5,
'12.5',
'12,5',
'12,5h',
'12:30',
'12:30:00',
'45000s',
'12:30',
'24:30', # throw a notice
'12.33'
];
$format='H:i';
echo PHP_EOL, "Ungerundet:", PHP_EOL;
foreach ( $arr as $time ) {
echo $time , ": " , timeS2timeF( $time, $format ) , PHP_EOL;
}
echo PHP_EOL, "Auf Minuten gerundet:", PHP_EOL;
foreach ( $arr as $time ) {
echo $time , ": " , timeS2timeF( $time, $format, 'm' ) , PHP_EOL;
}
echo PHP_EOL, "Auf Stunden gerundet:", PHP_EOL;
foreach ( $arr as $time ) {
echo $time , ": " , timeS2timeF( $time,$format, 'h' ) , PHP_EOL;
}
$s='07:00';
$d='8,75h';
echo "Arbeitsbeginn: $s (",
timeS2timeF($s, 'U'),
") - Arbeitszeit: $d (",
timeS2timeF($d, 'U'),
') - Arbeitsende: ',
timeS2timeF( timeS2timeF($s, 'U') + timeS2timeF($d, 'U') . 's', 'H:i'),
PHP_EOL ;
$s='22:00';
$d='8,75h';
echo "Arbeitsbeginn: $s (",
timeS2timeF($s, 'U'),
") - Arbeitszeit: $d (",
timeS2timeF($d, 'U'),
') - Arbeitsende: ',
timeS2timeF( timeS2timeF($s, 'U') + timeS2timeF($d, 'U') . 's', 'H:i'),
PHP_EOL ;