SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dates Not working?

    I am having a wierd issue getting dates from my MySQL database. I have tried two different methods. First I captured the output of time() and put it in a field, and then parsed it using date().

    The second method, and the one I would like to get working is setting the column type to timestamp and inputting NULL, so mysql fills it with the current time.

    I have a very wierd issue. When I insert using time, its in seconds from the unix equinox so I get a time like this: 1058624154

    When inserting MySQL timestamps I get: 20030719101014

    I understand that I have to select the date as a UNIX_TIMESTAMP() from MySQL.

    The problem is that whichever method I choose, I still get 0 which date parses as 7pm on December 31st, 1969. It seems that the data I'm selecting is not getting from the database to the date function to be parsed. I have tried directly outputting it, with no success, I can't seem to select the column.

    Here is my query:
    $query="SELECT news.story, news.title, news.date, SUBSTRING_INDEX(news.body, '.', 4) as body, users.name FROM news, users WHERE news.author=users.id ORDER BY news.story DESC LIMIT 10";

    Not using UNIX_TIMESTAMP() because I just want to get some output!

  2. #2
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Must have been a typo, everything is working now.


Bookmarks

Posting Permissions

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