0 0 Votes

PHP: Error "Call to undefined function now()"

Question by Guest | 24/07/2016 at 17:52

I want to retrieve the current date using PHP and I have written the following code for that:

$d = now();

echo date("d.m.Y", $d));

However, I get the following error when running this lines:

Fatal error: 
Uncaught Error: Call to undefined function now()

What am I doing wrong? How can I fix this error? And how can I determine and get the current timestamp in PHP as variable?


Stefan Trost

Show Profile | Message
-2Best Answer
2 Votes

The function now() is indeed available in some other programming languages, but not in PHP. There, for the same purpose, you can use the function time() instead:

$d = time();

echo date("d.m.Y", $d));

This code should output the current date.
25/07/2016 at 15:11

ReplyPositive Negative

Related Topics

"G" or "E" sign on my mobile
Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own articles on askingbox.com. How to do.