MySQL UTC_DATE() Function
The MySQL UTC_DATE() function returns the current UTC date. It returns the current date in the following format:
- Returns the current date as a 'YYYY-MM-DD' format, if used in a string context.
- Returns the current date as a YYYYMMDD format, if used in a numeric context.
Syntax
UTC_DATE()
Parameters
No parameter is required.
Return Value
Returns the current UTC date.
Example 1:
The example below shows the usage of UTC_DATE() function.
mysql> SELECT UTC_DATE(); Result: '2021-12-26' mysql> SELECT UTC_DATE() + 0; Result: 20211226 mysql> SELECT UTC_DATE() + 1; Result: 20211227
Example 2:
Consider a database table called Employee with the following records:
EmpID | Name | City | Age | Date_of_Joining |
---|---|---|---|---|
1 | John | London | 25 | 2018-05-25 |
2 | Marry | New York | 24 | 2018-10-15 |
3 | Jo | Paris | 27 | 2019-06-09 |
4 | Kim | Amsterdam | 30 | 2019-09-21 |
5 | Ramesh | New Delhi | 28 | 2019-10-25 |
To insert a new record in this table, the following statement can be used.
INSERT INTO Employee VALUES (6, 'Suresh', 'Mumbai', 28, UTC_DATE()); -- see the result SELECT * FROM Employee;
This will produce a result similar to:
EmpID | Name | City | Age | Date_of_Joining |
---|---|---|---|---|
1 | John | London | 25 | 2018-05-25 |
2 | Marry | New York | 24 | 2018-10-15 |
3 | Jo | Paris | 27 | 2019-06-09 |
4 | Kim | Amsterdam | 30 | 2019-09-21 |
5 | Ramesh | New Delhi | 28 | 2019-10-25 |
6 | Suresh | Mumbai | 28 | 2021-12-26 |
❮ MySQL Functions