Giacomo P. Mon Jul 19 17:14:46 -0400 2010

Subject: Object to string

Hi, I'm getting this error in PHP page with mysql dB connection:
Warning: strtotime() expects parameter 1 to be string, object given in ... on line 36

at the 36th line i get:
$lastaccess = strtotime($info['lastaccess']);

where $info is ...

$info = array();
$user = User::find($userid);
$info['lastaccess'] = $user->lastaccess;

My question is... how can i get the string instead of object in the last line of code?
Thank you

P.S. in the dB lastaccess is "date" type


Kien La Mon Jul 19 20:41:15 -0400 2010

date and datetime fields are converted to DateTime objects so if you wanted the unix timestamp you can do $user->lastaccess->getTimestamp();

(1-1/1)