Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the ways to get time in mysql

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail the ways to obtain time in mysql. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

1. Get the specified time

Function: date_format () conversion

# get the maximum value of the previous day's time SELECT date_format (CURRENT_DATE ()-1,'% Y-%m-%d 23 Y-%m-%d 59 Front_time 59') # define the time value, which is the current time on the hour SELECT @ time: = (SELECT CONCAT (CURRENT_DATE (),'', DATE_FORMAT (now (),'% H'),': 00VAN00')) # define the time value, which is SELECT @ front_time: = (SELECT CONCAT (CURRENT_DATE (),'', DATE_FORMAT (now (),'% H')-1))

Effect:

2. Get the current time: year-month-day hour: minute 2.1.Function now (): # get the format as current time: year-month-day hour: minute: second SELECT NOW ()

Effect:

2.2.2.The function SYSDATE () # is in the format of current time: year-month-day hour: minute: second SELECT SYSDATE ()

Effect:

2.3.The function current_timestamp () # is in the format of current time: year-month-day hour: minute: second SELECT current_timestamp ()

Effect:

Function: localtime () select localtime ()

Effect:

Function: localtimestamp () select localtimestamp ()

Effect:

3. Get the current time: year-month-day 3.1. Function: CURRENT_DATE () SELECT CURRENT_DATE ()

Effect:

Function: CURDATE () SELECT CURDATE ()

Effect:

Function: utc_date () #. * * because our country is located in the East eight time zone, local time = UTC time + 8 hours * * SELECT utc_date (); # utc_date () # utc_time () hours # utc_timestamp ()

Effect:

4. Return to the last day of the month

Function: last_day ()

Select last_day (NOW ())

Effect:

This is the end of this article on "what are the ways to obtain time in mysql?". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report