Here's an example of how to convert DATETIME to UNIX timestamp:
SELECT UNIX_TIMESTAMP(STR_TO_DATE('Apr 15 2012 12:00AM', '%M %d %Y %h:%i%p'))

Here's an example of how to change date format:
SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(STR_TO_DATE('Apr 15 2012 12:00AM', '%M %d %Y %h:%i%p')),'%m-%d-%Y %h:%i:%p')

Documentation: UNIX_TIMESTAMP, FROM_UNIXTIME

Answer from Query Master on Stack Overflow
🌐
w3resource
w3resource.com › mysql › date-and-time-functions › mysql-unix_timestamp-function.php
MySQL UNIX_TIMESTAMP() function - w3resource
2 weeks ago - MySQL UNIX_TIMESTAMP() returns a Unix timestamp in seconds since '1970-01-01 00:00:00' UTC as an unsigned integer if no arguments are passed with UNIX_TIMESTAMP(). When this function used with a date argument, it returns the value of the argument ...
🌐
w3resource
w3resource.com › mysql › date-and-time-functions › mysql-from_unixtime-function.php
MySQL FROM_UNIXTIME() function - w3resource
2 weeks ago - MySQL FROM_UNIXTIME() returns a date /datetime from a version of unix_timestamp. The return value is in ‘YYYYY-MM-DD HH:MM:SS’ format or YYYYMMDDHHMMSS.uuuuuu format depending upon the context of the function ( whether numeric or string).
🌐
DataCamp
datacamp.com › doc › mysql › mysql-unix-timestamp
MySQL UNIX_TIMESTAMP() Function: Usage & Examples
Note that the function returns an integer value representing seconds, not fractional seconds. sql SELECT * FROM events WHERE event_time < FROM_UNIXTIME(UNIX_TIMESTAMP() - 86400); In this example, the function is used to find all events that occurred more than 24 hours ago by comparing the event ...
🌐
MySQL
dev.mysql.com › doc › en › date-and-time-functions.html
MySQL :: MySQL 8.4 Reference Manual :: 14.7 Date and Time Functions
If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since '1970-01-01 00:00:00' UTC. The server interprets date as a value in the session time zone and converts it to an internal Unix timestamp value in UTC.
🌐
TutorialsPoint
tutorialspoint.com › how-to-convert-mysql-datetime-to-unix-timestamp
How to convert MySQL datetime to Unix timestamp?
July 30, 2019 - mysql> SELECT UNIX_TIMESTAMP(STR_TO_DATE('Oct 19 2018 10:00PM', '%M %d %Y %h:%i%p'));
🌐
GeeksforGeeks
geeksforgeeks.org › sql › unix_timestamp-function-in-mysql
UNIX_TIMESTAMP() function in MySQL - GeeksforGeeks
December 22, 2020 - UNIX_TIMESTAMP() : This function in MySQL helps to return a Unix timestamp. We can define a Unix timestamp as the number of seconds that have passed since ‘1970-01-01 00:00:00’UTC.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › mysql › mysql_date_time_functions_unix_timestamp.htm
MySQL - UNIX_TIMESTAMP() Function
The MySQL UNIX_TIMESTAMP() function converts the date, datetime, or timestamp expression to a UNIX timestamp and returns the result in the form of a string. This function accepts an optional date expression as an argument and returns the timestamp
🌐
Scaler
scaler.com › home › topics › mysql unix_timestamp() function
MySQL UNIX_TIMESTAMP() Function - Scaler Topics
July 17, 2023 - The DATETIME or TIMESTAMP data types in MySQL range between: 1000-01-01 00:00:00 to 9999-12-31 23:59:59 ... The MySQL UNIX_TIMESTAMP function returns the number of seconds elapsed from 1970-01-01 00:00:00 UTC till the date provided by the user.
🌐
Restack
restack.io › p › understanding-tinyint-vs-int-in-sql-answer-mysql-date-time-to-unix-timestamp
MySQL Date Time To Unix Timestamp | Restackio
May 3, 2025 - To convert a MySQL DATETIME value to a Unix timestamp, you can utilize the UNIX_TIMESTAMP() function. This function takes a DATETIME or DATE value and returns the corresponding Unix timestamp, which is the number of seconds since January 1, 1970.
🌐
Database Guide
database.guide › unix_timestamp-examples-mysql
UNIX_TIMESTAMP() Examples – MySQL
In this example, I provide a datetime value. SELECT UNIX_TIMESTAMP('2021-11-27 12:35:03') AS Result; ... As mentioned, if you provide a fractional seconds part, the return value will be a decimal value (as opposed to integer for the previous examples).
🌐
Metabase
discourse.metabase.com › get help
How can I convert Unix TimeStamp data to datetime format (dd/mm/yyyy)? - Get Help - Metabase Discussion
September 14, 2020 - I have in my Mysql database a table with the data values in Unix TimeStamp (milliseconds). Is there any form of conversion so that when displaying the query results it appears in the data format dd / mm / yyyy? For example, I want to program an indicator of processes started per month, so I ...
🌐
GeeksforGeeks
geeksforgeeks.org › sql › how-to-convert-timestamp-to-datetime-in-mysql
How to Convert Timestamp to Datetime in MySQL? - GeeksforGeeks
July 23, 2025 - In this article, we are going to ... these queries, we need to first add integer data(written in timestamp format) and then use the FROM_UNIXTIME() function to convert it into "Datetime" Data Type....
🌐
Epoch Converter
epochconverter.com
Epoch Converter - Unix Timestamp Converter
Epoch converter Batch converter ... Unix hex timestamp Cocoa Core Data timestamp Mac HFS+ timestamp NTP timestamp FAT timestamp SAS timestamp Excel OADate timestamp Seconds/days since year 0 Bin/Oct/Hex converter Year 2038 problem Countdown in seconds Epoch clock · Week numbers Weeks by year Day numbers Days by year Years/leap years Lunar phases Calculate the difference between two dates · Routines by language Epoch in C Epoch in MySQL Epoch in PERL ...
🌐
MySQL
bugs.mysql.com › bug.php
MySQL Bugs: #93328: Need ability to convert between unix timestamp values and dates without DST bugs
November 25, 2018 - Here is an example, using values that are distinct in the MET time zone: mysql> SET time_zone = 'MET'; mysql> SELECT UNIX_TIMESTAMP('2005-03-27 03:00:00'); +---------------------------------------+ | UNIX_TIMESTAMP('2005-03-27 03:00:00') | +---------------------------------------+ | 1111885200 | +---------------------------------------+ mysql> SELECT UNIX_TIMESTAMP('2005-03-27 02:00:00'); +---------------------------------------+ | UNIX_TIMESTAMP('2005-03-27 02:00:00') | +---------------------------------------+ | 1111885200 | +---------------------------------------+ mysql> SELECT FROM_UNIXTI
🌐
MySQL
dev.mysql.com › doc › refman › 8.0 › en › date-and-time-functions.html
MySQL :: MySQL 8.0 Reference Manual :: 14.7 Date and Time Functions
January 18, 2022 - For MySQL 8.0.28 and later running on 64-bit platforms, the valid range of argument values for UNIX_TIMESTAMP() is '1970-01-01 00:00:01.000000' UTC to '3001-01-19 03:14:07.999999' UTC (corresponding to 32536771199.999999 seconds). Regardless of MySQL version or platform architecture, if you pass an out-of-range date to UNIX_TIMESTAMP(), it returns 0.
🌐
MySQL Tutorial
mysqltutorial.org › home › mysql date functions › mysql unix_timestamp() function
MySQL UNIX_TIMESTAMP() Function
October 19, 2023 - UNIX_TIMESTAMP([date])Code language: SQL (Structured Query Language) (sql) ... date: This optional parameter specifies a date value that you want to convert into a Unix timestamp.