Reputation: 251
I'm having a problem with formatting date with date() function. My code is:
<?
$vysledek=mysql_query("select * from akce order by datum limit 1");
while ($zaznam=MySQL_Fetch_Array($vysledek))
echo
"<b>".$zaznam["nadpis"]."</b>"."<br />\n".
"<i>",
date("j.n.Y h:i", $zaznam["datum"]),
"</i>"."<br />\n"."<br />\n".
$zaznam["text"]."<br />\n"."<br />\n"."<br />\n";
?>
The whole data loaded from database displays correctly except the date, which returns 1.1.1970 01:33.
Upvotes: 1
Views: 199
Reputation: 219794
$zaznam["datum"]
probably isn't a timestamp which is the format the second parameter of date()
expects. Use strtotime()
to do this:
date("j.n.Y h:i", strtotime($zaznam["datum"]))
Upvotes: 3