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 = "[email protected]"'; 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 Link to comment https://forums.phpfreaks.com/topic/3419-using-from_unixtime/ 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 = "[email protected]"';[/code]Hope that helps. Link to comment https://forums.phpfreaks.com/topic/3419-using-from_unixtime/#findComment-11723 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.