RaelB RaelB - 1 year ago 79
PHP Question

Why does call to now() fail in php

Why does call to now() or current_timestamp() fail in simple php script?

try {
echo "Now: " . CURRENT_TIMESTAMP() . "<br>";
//echo "Time: " . time() . "<br>";

echo "Done";
catch(Exception $e) {
echo 'Message: ' .$e->getMessage();

The script returns a blank page, and no error is reported. time() worked fine.

Answer Source

NOW() and CURRENT_TIMESTAMP() are MySQL functions, not PHP functions.

As this link suggests, the function you are looking for is date("Y-m-d H:i:s"). Here is the documentation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download