Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Format 3

Status
Not open for further replies.

dbadmin

Programmer
Jan 3, 2003
147
US
Hi Gurus,

I have a MySQL database and it has one table with a date field and the format is as below '1212246855000'. How could I convert it to a valid mm/dd/yyyy hh:mi:ss format?

Thanks,
dbadmin
 
That format is 'epoch seconds' (have a Google for it)

It is a very useful format especially if passing data accross different languages. If you are using PHP there will be decoding routines already written for it. Not too sure on that as I use other languages for the same purpose.

Keith
 
Can you do a controled insert into the table e.g. run the app and note the time and then go and have a look what the column says.
do you access to the source code ?.
audiopro is corret, mysql has some function to convert date and times. Have you looked into these at Can you post the description of the table and highlight which column you have issues with, I'm curious to see know how you got the internal value .
 
I will stick by my original post of it being an epoch date. The difference is that in this form it is the number of milliseconds since 1970-01-01. I vaguely remember learning this many years ago bit I cannot remember why such accuracy was required. Remove the last three digits (convert to seconds) and you get a valid date.
Code:
31 May 2008 16:14:15 GMT

Keith
 
remove the last three digits"

DOH!! why ditn i think of that!

nice one, keith, star from me

dbadmin, your function call would be:
Code:
SELECT FROM_UNIXTIME(col/1000,'%m/%d/%Y %H:%i:%S') AS d

where [tt]col[/tt] is your column


r937.com | rudy.ca
 
Thank You everyone for the answer. from_UNIXTIME fixed the issue for me.

dbadmin.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top