Home >Backend Development >PHP Tutorial >Summary of commonly used MySQL date and time functions_PHP tutorial

Summary of commonly used MySQL date and time functions_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:17:59796browse

Get the current date + time (date + time) 1.1 Function: now()

    Related functions: current_timestamp(), localtime(), localtimestamp()

    Example:



    2. Get the current date (date)

    Function: curdate()

    Related functions: current_date(), current_date

    Example:



    3. Get the current time (time)

    Function: curtime()

    Related functions: current_time(), current_time

    Examples


    4. MySQL dayof…

    Functions: dayofweek(), dayofmonth(), dayofyear() return the date parameters and their positions in the week, month, and year respectively.

    Examples

    set @dt = '2008-08-08';

    select dayofweek(@dt); -- 6

    select dayofmonth(@dt); -- 8

    select dayofyear(@dt); -- 221

    The date ‘2008-08-08′ is the 6th day of the week (1 = Sunday, 2 = Monday, …, 7 = Saturday)

    The 8th day of January; the 221st day of the year

    www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325580.htmlTechArticleGet the current date + time (date+time) 1.1 function: now() related functions: current_timestamp(), localtime (), localtimestamp() Example: 2. Get the current date (date) Function:...
    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn