How to insert timestamp value into a Mysql table?

Asked

Viewed 635 times

-1

I am receiving a timestamp value from a request, and would like to store this value in my bank, however I want the column to interpret it correctly.

The value is 1416178487. And using the function date('d/m/y',1416178487); of PHP, it returns the date: 16/11/2014.

I wonder if there is a configuration for the table to receive the value like this: 1416178487 and show it like this: 16/11/2014.

  • Sorry for the mistake. Already adjusted. Thank you.

  • Blz, I’m gonna run some INSERT tests on the bank.

  • take a peek at the comment from Patrick, which explains how to use the FROM_UNIXTIME in Insert.

1 answer

2


You can select a column that contains a timestamp in Mysql as a date in that format by doing the following query:

SELECT FROM_UNIXTIME(coluna_timestamp, '%d/%m/%Y')
FROM minha_tabela;
  • 1

    @Tiagoamaral, I’m afraid just add the function to the insertion command: INSERT INTO tabela VALUES (FROM_UNIXTIME(1416178487)).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.