Hi
I'm having problems getting a correct date out of a mysql database:
The function to input the date seems to work fine:
function input_date($closure_date){
//$closure_date = a string of 2004-03-05
$conn = db_connect();
$sql = "update league set date = '";
$sql .= $closure_date . "' where leagueid = 13";
$r = mysql_query($sql, $conn);
if($r){
echo "success";
return $r;
}else{
echo "failure";
}
}
the date column in the database is of type 'date'.
But when I try to get the date out of the database it gives me a date back in 1970..
The function to access the date is as follows:
function getClosureDate(){
$conn = db_connect();
$sql = "select DATE_FORMAT(date,'%m %d %Y') from league";
$sql .= " where leagueid = 13";
$result = mysql_query($sql, $conn);
return mysql_fetch_array($result);
}
$result = getClosureDate();
if($result){
$time = strftime("%A %d/%m/%y", $result['date']);
echo '<br> time: ' . $time . '<br>';
}else{
echo "bugger";
}
I had some success previously accessing timestamp dates from the same database using:
DATE_FORMAT(date,'%M,%D,%Y') AS dateformatted
But this didn't seem to work this time..
Can someone please help!