Jump to content

how to get and convert


mga_ka_php

Recommended Posts

is it possible that i could get and convert the content of a column.

 

example.

id        message

1        have a message for you last 12993234

 

the 12993234 is a timestamp for example.

 

i want to have a sql statement that will get that timestamp and convert it to a date

 

example: SELECT id, message, (statement here) AS date FROM table1

 

id    message                                              date

1    have a message for you last 12993234      2009-02-16

 

12993234  --->  2009-02-16

 

the timestamp was converted to a date format of yyyy-mm-dd

 

is that possible? if possible how do i do that?

Link to comment
https://forums.phpfreaks.com/topic/146221-how-to-get-and-convert/
Share on other sites

DATE_FORMAT

 

 

 

And you will need to convert the unix timestamp to DATETIME first.

 

 

So something like:

 

DATE_FORMAT('%Y-%m-%d',  FROM_UNIXTIME(column_name));

 

 

 

 

I think that DATE might be in that format, so you might just be able to convert it to a date.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.