I get some dates from the database and use PHP strftime to format them.
Now everything works as planned, in addition, if I use the %A format, which should give me the full name of the day of the week, the function simply returns NULL if the date is not on the weekend, in which case it correctly returns “Saturday” or sunday.
All other formats work, even %A (short name of the day of the week). This does not seem to depend on the language used or on the specific date format (the same problem occurs if I just use strftime on mktime .
My only thought is that this is some incredibly strange server configuration problem, but I would like to hear if anyone has any other ideas about this ...
EDIT: some code, although this is pretty much what I wrote before ...
$id = (int)$_GET['event']; $res = mysql_query("SELECT date FROM events WHERE event_id=".$id); $row = mysql_fetch_array($res); echo strftime("%a %H:%M", $row['date']); echo strftime("%A %H:%M", $row['date']);
The first echo works fine, returning, for example, Thu 15:30 , the second returns NULL if $row['date'] does not fall on Saturday or Sunday.
If this can be useful, the code is inside the class, but I don’t see how this can affect the result ...
EDIT2: this is NOT a problem with the database or date format, otherwise the first echo will not work. Alternatively, I can simply delete the DB code and generate the date using mktime or using strtotime , and it still doesn't work.
EDIT3 (solution): found a problem. In Italian, the names of the days end with "(for example, lunedì), except Saturday and Sunday, which do not have accented letters. The result of the operation was passed to json_encode , which apparently does not like accented characters ... Call utf8_encode (or htmlentities ) solved a problem.