MySQL LOCALTIME() Function

MySQL Localtime() function; In this tutorial, i am going to show you MySQL localtime() function with the help of examples.

MySQL  LOCALTIME() Function

The LOCALTIME() function returns the current date and time. Note: The date and time is returned as “YYYY-MM-DD HH-MM-SS” (string) or as YYYYMMDDHHMMSS. uuuuuu (numeric).

Syntax of MySQL  LOCALTIME() Function

The syntax of localtime is:

LOCALTIME

====================================

LOCALTIME(optional)

Example 1 – MySQL  LOCALTIME() Function

Let’s take an example using the MySQL localtime(); as follows:

SELECT LOCALTIME;

Output-1

+---------------------+
| LOCALTIME           |
+---------------------+
| 2019-07-19 15:22:45 |
+---------------------+

Example 2 – MySQL  LOCALTIME() Function

Let’s take the second example with an optional argument to specify the fractional seconds precision for the return value; as follows:

SELECT LOCALTIME(6);

Output-2

+----------------------------+
| LOCALTIME(6)               |
+----------------------------+
| 2019-07-19 15:23:23.380839 |
+----------------------------+

Example 3 – MySQL  LOCALTIME() Function

Let’s take an example using localtime() with numeric context; as follows:

SELECT LOCALTIME + 0;

Output-3

+----------------+
| LOCALTIME + 0  |
+----------------+
| 20180628152338 |
+----------------+

Example 4 – MySQL  LOCALTIME() Function

Let’s take an example using MySQL Localtime() with a nonzero or with zero value; as follows:

SELECT 
    LOCALTIME + 0,
    LOCALTIME + 4;

Output-4

+----------------+----------------+
| LOCALTIME + 0  | LOCALTIME + 5  |
+----------------+----------------+
| 20190720015212 |  20190720015216|
+----------------+----------------+

Conclusion

MySQL  LOCALTIME() Function tutorial, you have learned how to use MySQL LOCALTIME() function with various examples.

Be First to Comment

Leave a Reply

Your email address will not be published.