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