Probleem bij UNIX timestamp
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
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
<?php
$sql9 = "SELECT productietijd, begintijd FROM spelproductie WHERE id = '".$row2['id']."'";
$res9 = mysql_query($sql9);
$row9 = mysql_fetch_array($res9);
setlocale (LC_TIME, "nl_NL");
$begintijd = $row9['begintijd'];
$productietijd = $row9['productietijd'];
$unixts_begintijd = strtotime($begintijd);
$productietijd_array = explode(':', $productietijd);
$unixts_eindtijd = $unixts_begintijd + ($productietijd_array[0] * 3600) + ($productietijd_array[1] * 60) + $productietijd_array[2];
if(time() > $unixts_eindtijd )
{
echo'<TD ALIGN="right" STYLE="middle: 9px">-</TD></TR>';
}
else
{
$unixts_duur = $unixts_eindtijd - time();
$duur = strftime('%H:%M:%S', $unixts_duur);
echo'<TD ALIGN="right" STYLE="middle: 9px">'.$duur.'</TD></TR>';
}
?>
$sql9 = "SELECT productietijd, begintijd FROM spelproductie WHERE id = '".$row2['id']."'";
$res9 = mysql_query($sql9);
$row9 = mysql_fetch_array($res9);
setlocale (LC_TIME, "nl_NL");
$begintijd = $row9['begintijd'];
$productietijd = $row9['productietijd'];
$unixts_begintijd = strtotime($begintijd);
$productietijd_array = explode(':', $productietijd);
$unixts_eindtijd = $unixts_begintijd + ($productietijd_array[0] * 3600) + ($productietijd_array[1] * 60) + $productietijd_array[2];
if(time() > $unixts_eindtijd )
{
echo'<TD ALIGN="right" STYLE="middle: 9px">-</TD></TR>';
}
else
{
$unixts_duur = $unixts_eindtijd - time();
$duur = strftime('%H:%M:%S', $unixts_duur);
echo'<TD ALIGN="right" STYLE="middle: 9px">'.$duur.'</TD></TR>';
}
?>
Nou is het probleem dat ik een uur teveel krijg. De invoerwaarden kloppen wel gewoon. Het script werkt prima maar ik moet dit te zien krijgen:
00:12:15 , maar krijg natuurlijk weeer dit te zien:
01:12:15
Dus wie ziet wat ik fout heb gedaan?
SELECT
UNIX_TIMESTAMP(Tijd) AS unixtijd,
En waarom zou ik dat doen?
wel je wil toch de unix timestamp dus ik selecteer hem zo, mischien kun je het zo een probere?
Jongens....wat is er fout aan dit script...andere functies heb ik niet nodig... En hoe zou ik dit kunnen oplossen
Als je geen andere functie wil dan doe je toch gewoon -3600?
Het zit zo ik werk met de timestamp omdat TIMEDIFF() niet werkt in mijn mysql versie. En eventuele andere oplossingen ook niet.
Ow het is al gelukt...de time() deed vaag. Dat is nu opgelost.