I need help converting a DATE format to STRING format.
I have a variable from a mysql database column which is type DATE.
I want to perform the php explode() function on it, however I get an error saying the parameter must be a string.
This is the code to get the variable from the database:
$duedate = mysql_query("SELECT duedate FROM mtt_todolist WHERE id=$id") ;
I Then want to use the explode() function on $duedate…
$date = explode("-", $duedate);
I get this error:
Warning: explode() expects parameter 2 to be string,
So I need to convert $duedate to type string. Any help? Thank you.
$duedateis a resource, you need to usemysql_fetch_(something)to access a row of that resource. (There are several functions whose names start withmysql_fetch.)I changed it so that $result is the resource, $row is a row out of that resource, and
$duedateis the data you’re after.Use
DATE_FORMATas suggested by @Steve in your code before this.