Ik wil datums zoals:
zaterdag 12-1-2002 om 12:00
dinsdag 5-2-2002 om 20:10
enz omzetten in het datetime formaat. Daarvoor heb ik dit script:
<?php
mysql_connect("localhost", "djenzie", "******") or die (mysql_error());
mysql_select_db("rhonrad") or die (mysql_error());
$select = mysql_query("SELECT * FROM oud_gastenboek order by id limit 0,10");
$aantal = mysql_num_rows($select);
$inserted = 0;
while($list = mysql_fetch_assoc($select)){
$tijd = substr($list['datum'],-5) .':00';
$spatiepos = strpos($list['datum'],' ');
$minpos = strpos($list['datum'],'-', $spatiepos);
$lengte= $minpos - $spatiepos - 1;
$dag = substr($list['datum'], $spatiepos + 1,$lengte);
$nxtminpos = strpos($list['datum'],'-', $minpos);
$lengte = $nxtminpos - $minpos - 1;
$mnd = substr($list['datum'], $minpos + 1,$lengte);
$jaar= substr($list['datum'], $nxtminpos + 1,4);
$nieuwedatum = $jaar.'-'.$mnd.'-'.$dag.' '.$tijd;
echo $nieuwedatum."<br>";
}
?>
Maar nu komt het er zo uit:
1-20-1-2002 om 12:0-12 12:00:00
spam
[ Voor 15% gewijzigd door whoami op 11-08-2003 16:28 ]