1

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.

1 Answer 1

3

$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"]))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.