Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to convert UNIX timestamp to MySQL

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 16-05-2009
Member
 
Join Date: Mar 2008
Posts: 349
How to convert UNIX timestamp to MySQL
  

I have columns in a table defined with a date 'YYYY-MM-DD' (data type: date) and time 'HH-MM-SS "(data: time) must.

Now I would like the entries in / out lines and such are within a defined date. For each line, the overall total of the time are calculated.

I get a multi figure I assume that it is the Unixtimestamp act. How do I reformat now, again a time HH-MM-SS arises. For example, 68:50:00.

Reply With Quote
  #2  
Old 16-05-2009
Member
 
Join Date: May 2008
Posts: 249
Re: How to convert UNIX timestamp to MySQL

Timestamp format in Mysql Datetime in general when you change

select FROM _UNIXTIME (int timestatmp)

If an opposition?

select TO_UNIXTIME (datetime)

select UNIX _TIMESTAMP (datetime)
Reply With Quote
  #3  
Old 16-05-2009
Member
 
Join Date: May 2008
Posts: 209
Re: How to convert UNIX timestamp to MySQL

Why you walking the timestamp is not equal when you save the DB in order? Obviously has the disadvantage that because you no longer so closely with the time stamp can sort. you can easily do it in PHP.


Quote:
<?php

/**
*
* @convert UNIX TIMESTAMP to MySQL TIMESTAMP
*
* @param int $timestamp
*
* @return string
*
*/
function unixToMySQL($timestamp)
{
return date('Y-m-d H:i:s', $timestamp);
}


/*** example usage ***/
$time = time();
echo unixToMySQL($time);

?>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to convert UNIX timestamp to MySQL"
Thread Thread Starter Forum Replies Last Post
How to convert UTC timestamp value to date and time AsceTic! MS Office Support 2 02-02-2012 06:14 PM
How can I see MySQL server running on Linux/ UNIX Wamilr Software Development 3 12-11-2010 11:55 AM
Javascript Unix Timestamp Zool Software Development 3 30-10-2009 08:30 AM
How to convert MYSQL into Readable PHP timestamp Aanand Software Development 2 15-05-2009 11:26 PM
Criteria with timestamp in MySQL Kirt Software Development 3 09-05-2009 12:09 PM


All times are GMT +5.5. The time now is 10:20 AM.