?
Solved

Convert Unix Timestamp to date?

Posted on 2005-04-04
7
Medium Priority
?
666 Views
Last Modified: 2008-01-09
I am working on a php project and am looking for a way to convert a unix timestamp to a data field with out using php (i already know how to do that).

I need to convert it in the sql query because i have developed a way to display the results of a query automatically in a query... Does mysql have such a feature...
 

here is my sql querythat i am using!..


      $sql = "SELECT invoice.invoicenum as 'Invoice',
               invoice.date as 'Date',
               invoice.finaltotal as 'Final Total',
               invoice.total as 'Total',
               invoice.activity,
               CONCAT(customer.firstname,' ',customer.lastname) as 'Customer Name',
               CONCAT(vin.year,' ',vin.make,' ',vin.model) as 'Vehical',
               customer.address as Address,
               customer.plate as Plate,
               users.user_name as 'Employee'"


      . ' FROM invoice'
      . ' LEFT JOIN customer ON invoice.customer_id = customer.customer_id'
      . ' LEFT JOIN users ON invoice.user = users.id'
      . ' LEFT JOIN vin ON invoice.vin_id = vin.id'
      . ' WHERE invoice.activity =\'incomplete\''
      . ' ORDER BY `invoice`.`date` DESC ';
0
Comment
Question by:mightofnight
  • 4
  • 3
7 Comments
 
LVL 2

Author Comment

by:mightofnight
ID: 13702997
this is my uinx timestamp field ( invoice.date as 'Date', )  example fild data is    1112421639
0
 
LVL 10

Expert Comment

by:kupra1
ID: 13703054
use
SELECT FROM_UNIXTIME(invoice.date) as 'Date',

>> instead of  
invoice.date as 'Date',
0
 
LVL 10

Expert Comment

by:kupra1
ID: 13703069
or use
SELECT FROM_UNIXTIME(invoice.date, '%Y %D %M %h:%i:%s %x');

to display in this format.
'2005 4th April 05:11:58 2005'
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 2

Author Comment

by:mightofnight
ID: 13703079
Hum that was pretty simple.. any advice on formatting?.. Now i am looking to format this i have found some commands but i can't find a collection of them..  I can't seem to find what i am looking for on the mysql website either..
0
 
LVL 2

Author Comment

by:mightofnight
ID: 13703084
:D you beat me to it i guess.. thouse are the commands taht i found are there anymore?
0
 
LVL 10

Accepted Solution

by:
kupra1 earned 2000 total points
ID: 13703462
0
 
LVL 2

Author Comment

by:mightofnight
ID: 13703475
Thanks a lot!
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question