adrianjohnson
Programmer
I have two date fields in an mySQL DB - AppDate and AppAinsDate - both are declared as DATE data types in mySQL and have 2004-04-01 and 2004-05-10 as values in them, respectively.
In an attempt to retrieve these values from the db, I used two methods.
Code:
$sql = "SELECT AppID, DATE_FORMAT(AppDate, '%d %m %Y') AS ApptDate, AppAInsDate FROM table";
$appt = mysql_query($sql, $db);
$ADdy = date('d',mysql_result($appt,0,"AppAinsDate"));
$ADmn = date('m',mysql_result($appt,0,"AppAinsDate"));
$ADyr = date('Y',mysql_result($appt,0,"AppAinsDate"));
ApptDate displays correctly when output to screen. However, if I use the date function in PHP all dates are displayed as 01/01/1970 !!!
So, how can I seperate the day/month/year from the values? I'd prefer to do it in PHP, as there are alot of dates in the SELECT statement (I took them all out to shorten the space taken here) so I'd rather retreive the dates in their mySQL format, then use PHP to manipulate them. The date command shown above does not work.
Thanks,
Adrian Johnson
In an attempt to retrieve these values from the db, I used two methods.
Code:
$sql = "SELECT AppID, DATE_FORMAT(AppDate, '%d %m %Y') AS ApptDate, AppAInsDate FROM table";
$appt = mysql_query($sql, $db);
$ADdy = date('d',mysql_result($appt,0,"AppAinsDate"));
$ADmn = date('m',mysql_result($appt,0,"AppAinsDate"));
$ADyr = date('Y',mysql_result($appt,0,"AppAinsDate"));
ApptDate displays correctly when output to screen. However, if I use the date function in PHP all dates are displayed as 01/01/1970 !!!
So, how can I seperate the day/month/year from the values? I'd prefer to do it in PHP, as there are alot of dates in the SELECT statement (I took them all out to shorten the space taken here) so I'd rather retreive the dates in their mySQL format, then use PHP to manipulate them. The date command shown above does not work.
Thanks,
Adrian Johnson