Epoch Converter and Date/Time in MySQL

Quick Navigation

Date and Time functions



    SELECT "CURRENT_TIMESTAMP: ";
    SELECT CURRENT_TIMESTAMP;

    SELECT "CURRENT_TIME: ";
    SELECT CURRENT_TIME;

    SELECT "CURRENT_DATE: ";
    SELECT CURRENT_DATE;

    SELECT "YEAR(CURRENT_DATE): ";
    SELECT YEAR(CURRENT_DATE);
    SELECT "MONTH(CURRENT_DATE): ";
    SELECT MONTH(CURRENT_DATE);
    SELECT "MONTHNAME(CURRENT_DATE): ";
    SELECT MONTHNAME(CURRENT_DATE);
    SELECT "DAY(CURRENT_DATE): ";
    SELECT DAY(CURRENT_DATE);
    SELECT "DAY('2019-02-12'): ";
    SELECT DAY('2019-02-12');

    SELECT "HOUR(CURRENT_TIMESTAMP): ";
    SELECT HOUR(CURRENT_TIMESTAMP);
    SELECT "MINUTE(CURRENT_TIMESTAMP): ";
    SELECT MINUTE(CURRENT_TIMESTAMP);

                

Output:



    CURRENT_TIMESTAMP:
    2019-02-13 02:10:33
    CURRENT_TIME:
    02:10:33
    CURRENT_DATE:
    2019-02-13
    YEAR(CURRENT_DATE):
    2019
    MONTH(CURRENT_DATE):
    2
    MONTHNAME(CURRENT_DATE):
    February
    DAY(CURRENT_DATE):
    13
    DAY('2019-02-12'):
    12
    HOUR(CURRENT_TIMESTAMP):
    2
    MINUTE(CURRENT_TIMESTAMP):
    10

                


Unix Time to Date



    SELECT FROM_UNIXTIME(1550024147);

                

Output:



    2019-02-13 02:15:47

                


Date to Unix Time



    SELECT "current unix time: ";
    SELECT UNIX_TIMESTAMP();

    SELECT "UNIX_TIMESTAMP('2019-02-12 00:00:00'): ";
    SELECT UNIX_TIMESTAMP("2019-02-12 00:00:00");

                

Output:



    current unix time:
    1550024854
    UNIX_TIMESTAMP('2019-02-12 00:00:00'):
    1549929600

                


Programming Languages: