Results 1 to 3 of 3

Thread: How to convert UNIX timestamp to MySQL

  1. #1
    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.

  2. #2
    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)

  3. #3
    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.


    <?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);

    ?>

Similar Threads

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •