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 convert date to timestamp in mysql

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

Share

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

This article focuses on "how to change a date into a time stamp in mysql". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to change a date into a timestamp in mysql".

In mysql, you can use the unix_timestamp () function to convert a date to a timestamp with the syntax "UNIX_TIMESTAMP (date)"; this function returns the value of the "date" parameter as the number of seconds after "1970-01-01 00:00:00'GMT", that is, a timestamp.

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

Mysql converts the date to a timestamp

In mysql, you can use the unix_timestamp () function to convert a date to a timestamp.

Syntax:

UNIX_TIMESTAMP (date)

The unix_timestamp () function, if called with no arguments, returns an unsigned integer type UNIX timestamp (seconds after '1970-01-01 00:00:00'GMT).

If you call UNIX_TIMESTAMP () with date, it returns the parameter value as the number of seconds after '1970-01-01 00:00:00'GMT.

Example:

1. Transfer to ten places--

Select UNIX_TIMESTAMP ('2018-12-25-12-12-25-25-25-25-25-25-12-25-25-12-25-25-12-25-25-25-25-12-2018-12-25-25-12-25-25-12-25-25-12-25-25-12-25-12-12-25-12-25-12-25-12-12-25-12-25-12-12-25-12-25-12-12-25-12-12-25-12-12-25-12-12-25-12-12-25-12-12-25-12-25-12-25-12-12-25-12-12-25-12-25-12-25-12-25-25-12-25-12-25 25-25-12)

Results:

1545711900

2. Transfer to thirteen places

SELECT REPLACE (unix_timestamp (current_timestamp (3)),'.')

Results:

1545711900021 so far, I believe you have a deeper understanding of "how to convert a date into a timestamp in mysql". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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