Jump to content

Archived

This topic is now archived and is closed to further replies.

Michael

Using FROM_UNIXTIME()

Recommended Posts

Hello

I 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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.