Michael Posted February 14, 2006 Share Posted February 14, 2006 HelloI am trying to figure out out to use FROM_UNIXTIME(). I can create the time stame with UNIX_TIMESTAMP, but converting to a human readable format has me stumped. All the examples I can find have not been very helpful.Example code:$sql_query = 'SELECT FROM_UNIXTIME(artists_artist_avatar) FROM ' . ARTISTS_TABLE . ' WHERE artists_artist_email = "ofelia@iac.com"'; if(!$result_time = $db->sql_query($sql_query)) { message_die(CRITICAL_ERROR, "Could not query user information in admin_artists", "", __LINE__, __FILE__, $sql_query); } $row = $db->sql_fetchrow($result_time); echo('time ---> ' . $row[artists_artist_avatar]); where I have verified that the reference3d field contains the time stamp, 1139899217, to be precise.When I run the query the echo statment shows no time.I would appreciate it very much if someone could put me right.Thanks Quote Link to comment Share on other sites More sharing options...
fenway Posted February 14, 2006 Share Posted February 14, 2006 Of course it doesn't -- you have returned no such field named 'artists_artist_avatar'. Instead, you have returned the expression you calculated. Simply add an alias to your query, and then your $row hash will contain the desired key:[code]$sql_query = 'SELECT FROM_UNIXTIME(artists_artist_avatar) AS artists_artist_avatar FROM ' . ARTISTS_TABLE . ' WHERE artists_artist_email = "ofelia@iac.com"';[/code]Hope that helps. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.