Results 1 to 2 of 2
Thread: Dates Not working?
Jul 19, 2003, 07:12 #1
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!
Jul 19, 2003, 07:21 #2