Categories > TinyButStrong general >

Wrong conversion of PHP timestamps with frm

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Basti
Date: 2008-11-11
Time: 15:04

Wrong conversion of PHP timestamps with frm

Hi,

I have a strange problem with the TinyButStrong frm-function. I want to convert a PHP timestamp, selected from a database (INT(11)), into a date/time format.
In my template, I use this code:

[entry.time;frm=dd.mm.yyyy - hh:nn]

Usually, the timestamp is converted correctly, but recently I got some wrong formattings. Those mistakes apparently occur at random, anyway only a few timestamps  - especially the year - are formatted wrongly.
The timestamps in the database are correct (for example 1225130426 and 1225469435, the year of the first one with frm is 9435). The PHP date-function provides the right date (year 2008).

I'm using the newest version of TinyButStrong (3.4.0).

Is there known any bug concerning the conversion of PHP timestamps with frm?
By: Skrol29
Date: 2008-11-11
Time: 16:19

Re: Wrong conversion of PHP timestamps with frm

Hi,

There is no such known bug.
Do you have a snippet to reproduce the behavior ?
By: Basti
Date: 2008-11-11
Time: 19:26

Re: Wrong conversion of PHP timestamps with frm

I am also surprised by this problem because everything seems to be right, except the year. The strange thing is, that its apperently every 5th entry or similar to be formatted wrong.

My whole template-file looks like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <title>Gästebuch</title>
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <link rel="stylesheet" type="text/css" href="[var.domain]/[var.root]/modules/guestbook/frontend/stylesheet.php" />
</head>

<body>

<div id="root">
  <i>[var.status;if [val]=0;then 'Das Gästebuch-Modul ist zur Zeit deaktviert!';else '';magnet=i]</i>
  <div style="margin: 10px 0;">
    Zur Zeit sind [entries.#] Einträge im Gästebuch.<br />
    <a href="[var.gb_add]?[var.session_name]=[var.session_id]">&middot; Ins Gästebuch eintragen</a>
    [var.status;if [val]=1;then ' ';else '';magnet=span]
  </div>
  <div class="[var.msg_type]">
    [var.msg_title]
    <ul>
      <li>[msg_text.val;block=li;bmagnet=div]</li>
    </ul>
    [var.msg_type;if [val]!='';then ' ';else '';magnet=div]
  </div>
  <i>[entries;block=i;nodata]Es konnten keine Einträge gefunden werden!</i> 
  <table class="gaestebuch">
    <tr>
      <th class="name">&raquo; [entries.name;ope=max:60;block=table;onformat=html_decode;when [var.status]=1]</th>
      <td class="links">
        [entries.email;if [val]!='';then '<a href="mailto:[entries.email;onformat=html_decode]"><img src="[var.domain]/[var.img_path]/guestbook/email.png" alt="Email" class="icon" /></a>';else '']
        [entries.page;if [val]!='';then '<a href="[entries.page;onformat=html_decode]" target="_blank"><img src="[var.domain]/[var.img_path]/guestbook/homepage.png" alt="Homepage" class="icon" /></a>';else '']
        [entries.icq;if [val]!='';then '<a href="http://www.icq.com/people/about_me.php?uin=[entries.icq;onformat=html_decode]"><img src="http://wwp.icq.com/scripts/online.dll?icq=[entries.icq;onformat=html_decode]&amp;img=5" alt="ICQ" class="icon" /></a>';else '']
      </td>
    </tr>
    <tr>
      <td colspan="2" class="date">erstellt am [entries.time;frm=dd.mm.yyyy - hh:nn] Uhr</td>
    </tr>
    <tr>
      <td colspan="2" class="message">
        [entries.message;onformat=bb_code]
        <div class="comment">
          <b>Kommentar:</b><br />
          [entries.comment;onformat=bb_code]
          [entries.comment;if [val]!='';then ' ';else '';magnet=div]
        </div>
      </td>
    </tr>
  </table>
  <p class="site_bar">
    <a href="[var.php_self]?p=[nv.first;endpoint;magnet=a]">|&laquo;</a>
    <a href="[var.php_self]?p=[nv.prev;endpoint;magnet=a]">&laquo;</a>
    <a href="[var.php_self]?p=[nv.page;block=a;navsize=5;navpos=centred;bmagnet=p]">[nv.page]</a>
    <b>[nv.page;block=b;currpage]</b>
    <a href="[var.php_self]?p=[nv.next;endpoint;magnet=a]">&raquo;</a>
    <a href="[var.php_self]?p=[nv.last;endpoint;magnet=a]">&raquo;|</a>
  </p>
</div>

</body>

</html>

This is the according PHP part (only the important extract):
$TBS->LoadTemplate("/modules/guestbook/frontend/index.tpl", FALSE);
   
# get entries
$TBS->PlugIn(TBS_BYPAGE,$entries_per_page,$page_num,-1);
$rec_cnt = $TBS->MergeBlock('entries', $db, "SELECT name, message, email, page, icq, comment, time FROM {$db_prefix}guestbook ORDER BY time DESC");
$TBS->PlugIn(TBS_NAVBAR,'nv','',$page_num,$rec_cnt,$entries_per_page);
$TBS->MergeBlock('entries_err', $db, "SELECT id, title, time FROM {$db_prefix}guestbook ORDER BY time DESC LIMIT 1");

$TBS->Show(TBS_OUTPUT);

$entries_per_page has got the value 5, $page_num the page-number (depending on page 1,2, ...).

I hope that helps you.
By: Basti
Date: 2008-11-19
Time: 14:49

Re: Wrong conversion of PHP timestamps with frm

Don't you have any idea?
By: Manuel
Date: 2009-01-21
Time: 13:35

Re: Wrong conversion of PHP timestamps with frm

Hey!

I am having the same problem. The timestamp is saved correctly in the database, but the output ist wrong. I am having this problem only with one timestamp for this date: 12.08.2008.
If I enter the 13.08.2008 everything is correct, but it seems, that there is a problem with some kind of date format.
My output is always the 21.01.2000 if I enter this special date.

Thank you very much for your reply. Otherwise I have to use the php-date-function, although I really like the frm-handling.


Nice greetings,
Manuel