Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2008
    Posts
    36

    Question Unanswered: display date format as dd-mm-yy in PHPMyAdmin

    Hey all,
    It's my first post here and I'm also a MySQL noob, but I know a few things, just not this

    I have a table that has the following structure:
    Field = timevalue
    Type= varchar(12)
    Value = 1187962147

    I'd like to see the date Value displayed as dd-mm-yy instead of 1187962147 in PHPMyAdmin. How?
    TIA!
    Leafgreen

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    okay, first of all, you should be using INTEGER, not VARCHAR

    to display a unix epoch number as a date, use the FROM_UNIXTIME function

    might not work on a string, but maybe mysql will convert it implicitly
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2008
    Posts
    36
    Quote Originally Posted by r937
    use the FROM_UNIXTIME function
    Hey r937 I did that and got this error:
    tbl_replace.php: Missing parameter: goto (FAQ 2.8)
    Last edited by Leafgreen; 04-08-08 at 22:03.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    okay, would you like me to move this thread to the php forum?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Apr 2008
    Posts
    36
    ok sure. Thanks

  6. #6
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    If you're using PHPMyAdmin you're going to have to convert it using the SQL syntax, however if you intend to extra the information from MySQL first then parse it in your own PHP script then consider using:
    Code:
    $date = '1187962147';
    $date = date('d-m-Y', strtotime($date));
    echo $date;

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    sounds like a good reason to revisit the dsign of the db and fix the problem in the first place.. store a date as a date and be doen with the problem.

  8. #8
    Join Date
    Apr 2008
    Posts
    36
    Thanks all.
    store a date as a date
    Right, I have no idea why the devs who designed the db used that system for the date.

  9. #9
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    somebody told them that integers were more efficient, and they drank the koolaid
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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