Hi all,
I have this starnge problem.
I try to get the datetime field out of mysql.
I use:
$arr=sql_fetch_array($result)
$date=$arr['mdate'];
This code used to work fine and I got the date in the format yyyy-mm-dd H:i:s just as it is in the db.
but now I use php 4.33 and I get just the year int the $date variable.
In the old version things still work good.
What is the problem?
getting date out of mysql
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
What do you get if you use print_r() on the row array, e.g.:
Does that date show up properly there? It may also be useful to see the SQL statement that you use to draw the information from the database.
Mac
Code: Select all
$row = mysql_fetch_array($result);
echo '<pre>';
print_r($row);
echo '</pre>';Mac
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
My guess would be something to do with conversion to an integer variable. PHP is not strongly typecast, but if you convert the string "2003-12-15 etc" into an interger variable and than back into a string you will get "2003" alone.
Not seeing all of your code is a handicap in diagnosing the problem, but look for anything that may be casting that element to an integer. Something in the more recent version may be more strongly typecasting than in the earlier version.
Not seeing all of your code is a handicap in diagnosing the problem, but look for anything that may be casting that element to an integer. Something in the more recent version may be more strongly typecasting than in the earlier version.