Hi I'm having a problem when trying to display the converted Unix time in a column. The code below is my sql statement which converts the UNIX format to a readable format. When running the sql query on a console it works perfect. However placing the converted date and time into a column seems to be the problem. I return an array called @transactions containing the results of the sql query.
my @transactions; my $sth = $db_h->Query(" SELECT serial_num, FROM_UNIXTIME(trans_date) AS 'Actio +n_date', actor, type, trans_data, content FROM transtable ORDER BY serial_num; "); $sth->execute(); while( my $trans_hash = $sth->fetchrow_hashref("NAME_lc") ) { push (@transactions,$trans_hash); } return @transactions;
Here I call the method returning the @transactions array. This is the line where I'm trying to print the date value
print " <td style='background-color:#f0f0f0;' ><b>$transaction->{'Act +ion_date'}</b></td>";
my @trans_array = (); my @trans_array = &Cpt::transactions_summary( $current_user ); foreach my $transaction (@trans_array) { print "<tr>"; print " <td style='background-color:#f0f0f0;' ><b>$transaction->{ +'serial_num'}</b></td>"; print " <td style='background-color:#f0f0f0;' ><b>$transaction->{ +'Action_date'}</b></td>"; + print " <td style='background-color:#f0f0f0;' ><b>$transaction->{ +'actor'}</b></td>"; print " <td style='background-color:#f0f0f0;' ><b>$transaction->{ +'type'}</b></td>"; print " <td style='background-color:#f0f0f0;' ><b>$transaction->{ +'trans_data'}</b></td>"; print " <td style='background-color:#f0f0f0;' ><b>$transaction->{ +'content'}</b></td>"; print "</tr>"; }
I really appreciate any feedback as I'm new to perl Thank you

In reply to Problem converting with FROM_UNIXTIME by ibra

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.