functie-tijd-parser
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
function tijdparser($seconden,$notatie=1){
if($seconden <= 0){
if($notatie == 1) {$code = "0 S";}
else {$code = "0 Seconden";}
}
else
{
$dagen = $seconden / 86400;
$dagen = floor($dagen);
$seconden2= $seconden - $dagen * 86400;
$uren = $seconden2 / 3600;
$uren = floor($uren);
$overig = $seconden2 - $uren * 3600;
$minuten = $overig / 60;
$minuten = floor($minuten);
$rest = $overig - $minuten * 60;
if($notatie == 1){
if($dagen >= 1) {$code = "$dagen D $uren U $minuten M $rest S";}
elseif($uren >= 1) {$code = "$uren U $minuten M $rest S";}
elseif($minuten >= 1) {$code = "$minuten M $rest S";}
elseif($rest >= 1) {$code = "$rest S";}
}
else
{
if($dagen >= 1){
if($dagen == 1) {$code = "1 Dag";}
else {$code = "$dagen Dagen";}
if($uren == 1) {$code .= " 1 Uur";}
else {$code .= " $uren Uren";}
if($minuten == 1) {$code .= " 1 Minuut";}
else {$code .= " $minuten Minuten";}
if($rest == 1) {$code.= " 1 Seconde";}
else {$code.= " $rest Seconden";}
}
elseif($uren >= 1){
if($uren == 1) {$code .= " 1 Uur";}
else {$code .= " $uren Uren";}
if($minuten == 1) {$code .= " 1 Minuut";}
else {$code .= " $minuten Minuten";}
if($rest == 1) {$code.= " 1 Seconde";}
else {$code.= " $rest Seconden";}
}
elseif($minuten >= 1){
if($minuten == 1) {$code .= " 1 Minuut";}
else {$code .= " $minuten Minuten";}
if($rest == 1) {$code.= " 1 Seconde";}
else {$code.= " $rest Seconden";}
}
elseif($rest >= 1){
if($rest == 1) {$code.= " 1 Seconde";}
else {$code.= " $rest Seconden";}
}
}
}
return $code;
}
?>
function tijdparser($seconden,$notatie=1){
if($seconden <= 0){
if($notatie == 1) {$code = "0 S";}
else {$code = "0 Seconden";}
}
else
{
$dagen = $seconden / 86400;
$dagen = floor($dagen);
$seconden2= $seconden - $dagen * 86400;
$uren = $seconden2 / 3600;
$uren = floor($uren);
$overig = $seconden2 - $uren * 3600;
$minuten = $overig / 60;
$minuten = floor($minuten);
$rest = $overig - $minuten * 60;
if($notatie == 1){
if($dagen >= 1) {$code = "$dagen D $uren U $minuten M $rest S";}
elseif($uren >= 1) {$code = "$uren U $minuten M $rest S";}
elseif($minuten >= 1) {$code = "$minuten M $rest S";}
elseif($rest >= 1) {$code = "$rest S";}
}
else
{
if($dagen >= 1){
if($dagen == 1) {$code = "1 Dag";}
else {$code = "$dagen Dagen";}
if($uren == 1) {$code .= " 1 Uur";}
else {$code .= " $uren Uren";}
if($minuten == 1) {$code .= " 1 Minuut";}
else {$code .= " $minuten Minuten";}
if($rest == 1) {$code.= " 1 Seconde";}
else {$code.= " $rest Seconden";}
}
elseif($uren >= 1){
if($uren == 1) {$code .= " 1 Uur";}
else {$code .= " $uren Uren";}
if($minuten == 1) {$code .= " 1 Minuut";}
else {$code .= " $minuten Minuten";}
if($rest == 1) {$code.= " 1 Seconde";}
else {$code.= " $rest Seconden";}
}
elseif($minuten >= 1){
if($minuten == 1) {$code .= " 1 Minuut";}
else {$code .= " $minuten Minuten";}
if($rest == 1) {$code.= " 1 Seconde";}
else {$code.= " $rest Seconden";}
}
elseif($rest >= 1){
if($rest == 1) {$code.= " 1 Seconde";}
else {$code.= " $rest Seconden";}
}
}
}
return $code;
}
?>