Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert human date to unix timestamp in Mysql?

Tags:

I have a table with a date field, having human date in it like: '2008-01-08 19:23:32' Now i have to copy this field plus some other fields of the same table to another table, but date needs to be in unix timestamp.

Is there any function in mysql which converts human date to unix timestamp inside query itself?

like image 755
developer Avatar asked Oct 14 '11 06:10

developer


People also ask

How do I manually convert a date to a TIMESTAMP in Unix?

To easily convert UNIX timestamp to date in the . csv file, do the following: 1. =R2/86400000+DATE(1970,1,1), press Enter key.

How do I convert a date to a TIMESTAMP in SQL?

We can convert the Date into Datetime in two ways. Using CONVERT() function: Convert means to change the form or value of something. The CONVERT() function in the SQL server is used to convert a value of one type to another type. Convert() function is used to convert a value of any type to another datatype.

What is Unix timestamp MySQL?

UNIX_TIMESTAMP() function in MySQL We can define a Unix timestamp as the number of seconds that have passed since '1970-01-01 00:00:00'UTC. Even if you pass the current date/time or another specified date/time, the function will return a Unix timestamp based on that. Syntax : UNIX_TIMESTAMP() UNIX_TIMESTAMP(date)

How do I create a TIMESTAMP in MySQL?

MySQL retrieves and displays DATETIME values in ' YYYY-MM-DD hh:mm:ss ' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59' . The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.


1 Answers

mysql> select unix_timestamp('2008-01-08 19:23:32');
+---------------------------------------+
| unix_timestamp('2008-01-08 19:23:32') |
+---------------------------------------+
|                            1199849012 |
+---------------------------------------+
1 row in set (0.04 sec)

found here: http://www.epochconverter.com/

like image 87
jcomeau_ictx Avatar answered Sep 21 '22 14:09

jcomeau_ictx