Home > PHP, Snippets of Code > NOW() function in SQLite

NOW() function in SQLite

NOW() function does not exist in SQLite. Instead use datetime(‘NOW’,’localtime’) as in the example:

<?prepare("SELECT datetime('NOW','localtime') AS now");
if (!$result) { echo "\nError SQLite::errorInfo(): "; print_r($dbsqlite->errorInfo()); }
$result->execute();
$data = $result->fetchAll();
$now_SQLite = $data[0][0];
$dbsqlite = NULL;
echo "\nSQLite Time: " . $now_SQLite;
?>

Advertisements
Categories: PHP, Snippets of Code Tags: , , , ,
  1. Anonymous
    2013/10/06 at 6:30 am

    Thanks a lot, very useful

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: