Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/3419-using-from_unixtime/
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.
Link to comment
https://forums.phpfreaks.com/topic/3419-using-from_unixtime/#findComment-11723
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.