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

How to use UNIX_TIMESTAMP function in MySQL

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

MySQL how to use UNIX_TIMESTAMP function, I believe that many inexperienced people are helpless about this, this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

The UNIX_TIMESTAMP function in MySQL has two types to call

1 No argument call: UNIX_TIMESTAMP()

Return value: Seconds difference from '1970-01-01 00:00:00' to current time

UNIX SELECT_TIMESTAMP() => 1339123415

UNIX_TIMESTAMP(date)

where date can be a DATE string, a DATETIME string, a TIMESTAMP, or a number in YYMMDD or YMMDD format for local time

Return value: Seconds difference from '1970-01-01 00:00:00' to specified time

Example: www.2cto.com

DATE string format: (date type)

SELECT UNIX_TIMESTAMP(‘2012-06-08’) => 1339084800

SELECT UNIX_TIMESTAMP(CURRENT_DATE()) =>1339084800

Note: The return value of CURRENT_DATE () is a DATE string format

The following formats return the same result:

SELECT UNIX_TIMESTAMP('20120608');

SELECT UNIX_TIMESTAMP('2012-6-8');

SELECT UNIX_TIMESTAMP('2012-06-08');

The result is: 1339084800

DATETIME string format: (combined type of date and time)

SELECT UNIX_TIMESTAMP(‘2012-06-08 10:48:55’) => 1339123415

SELECT UNIX_TIMESTAMP(NOW()) => 1339123415

Note: The return value of NOW() is a DATETIME string format

After reading the above, do you know how to use UNIX_TIMESTAMP function in MySQL? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!

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

Database

Wechat

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

12
Report