MySQL LOCALTIME and localtime() are the Functions which is useful to return the current date and time in YYYY-MM-DD HH:MM:SS.
In this article, we show you, How to use these LOCALTIME functions to get local DateTime with an example. The basic syntax of the local date and time is as shown below:
LOCALTIME;
LOCALTIME();
MySQL LOCALTIME Example
The following statements show you how to use these local time functions.
TIP: Both these MySQL Date methods are synonyms of the MySQL NOW(). All these three MySQL functions return the same output.
SELECT LOCALTIME;
SELECT LOCALTIME();
SELECT NOW();

As you can see, the above three statements return the local date and time in YYYY-MM-DD HH:MM:SS format. The below LOCALTIME statements show you what happens when adding a few seconds to the localtime() function. Also, read about the MySQL LOCALTIMESTAMP function.
SELECT LOCALTIME() + 2;
SELECT LOCALTIME + 22;
SELECT DATEDIFF(LOCALTIME, '2019-01-22');

From the above screenshot, you can see that this method added those extra seconds and displayed the date in string format, i.e., YYYYMMDDHHMMSS. Within the last statement, we used the DATEDIFF to find the difference between the local datetime and custom dt ‘2019-01-22.’ Please refer to the MySQL CURRENT_TIMESTAMP function