Mysql Now Function

MySQL: NOW Function

This tutorial explains how to use the MySQL NOW function with syntax and examples.

Description

The MySQL NOW function returns the current date and time.

Syntax

The syntax for the NOW function in MySQL is:

NOW( )

Parameters or Arguments

There are no parameters or arguments for the NOW function.

Note

  • The NOW function will return the current date as a 'YYYY-MM-DD HH:MM:SS' format, if used in a string context.
  • The NOW function will return the current date as a YYYYMMDDHHMMSS format, if used in a numeric context in versions of MySQL prior to MySQL 4.1.13.
  • The NOW function will return the current date as a YYYYMMDDHHMMSS.uuuuuu format, if used in a numeric context in versions of MySQL 4.1.13 and newer.
  • The CURRENT_TIMESTAMP, LOCALTIME, and LOCALTIMESTAMP functions are synonyms for the NOW function.

Applies To

The NOW function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let's look at some MySQL NOW function examples and explore how to use the NOW function in MySQL.

For example:

mysql> SELECT NOW();
Output: '2014-01-28 13:48:41'

mysql> SELECT NOW() + 0;
Output: 20140118134841.000000

mysql> SELECT NOW() + 1;
Output: 20140118134842.000000