I need to enter into a SQLite table a DATETIME
value. The date is originally been published with Italian month names but in different formats (see below). I need then to pre process the string before send it to the database. I thought then of using strftime
that would (hopefully) manage different formats after I specify that the locale for each format is Italian. This is what I tried
<?php
error_reporting(E_ERROR | E_PARSE);
$dates = array("16:19, 23 set 2010 (CEST)",
"10:52, 9 dic 2006 (CEST)",
"19:38, Ago 16, 2005 (CEST)",
"12:34, Ago 8, 2005 (CEST)",
"01:19, Apr 24, 2005 (CEST)");
print_r($dates);
foreach ($dates as $date) {
setlocale(LC_TIME, "it_IT");
$date = strftime($date);
echo $date."\n";
setlocale(LC_TIME, "en_AU");
echo $date."\n";
}
?>
Still the dates are not converted in a time format. They are not converted at all. This is the ouput:
(
[0] => 16:19, 23 set 2010 (CEST)
[1] => 10:52, 9 dic 2006 (CEST)
[2] => 19:38, Ago 16, 2005 (CEST)
[3] => 12:34, Ago 8, 2005 (CEST)
[4] => 01:19, Apr 24, 2005 (CEST)
)
16:19, 23 set 2010 (CEST)
16:19, 23 set 2010 (CEST)
10:52, 9 dic 2006 (CEST)
10:52, 9 dic 2006 (CEST)
19:38, Ago 16, 2005 (CEST)
19:38, Ago 16, 2005 (CEST)
12:34, Ago 8, 2005 (CEST)
12:34, Ago 8, 2005 (CEST)
01:19, Apr 24, 2005 (CEST)
01:19, Apr 24, 2005 (CEST)