?
Solved

Convert Unix Timestamp to date?

Posted on 2005-04-04
7
Medium Priority
?
655 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
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…
Suggested Courses

743 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