TinyButStrong - the PHP Template Engine
Categories > TinyButStrong general >

Date Timr Format Issues in 3.0

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Maz
Date: 2006-05-19
Time: 12:01

Date Timr Format Issues in 3.0

SQL Version      MYSQL (5.0.18-standard)
PHP Version     5.1.4 (cgi)

I noticed earlier today that the date formatting seems to have ceased working. I have the date time stored as INT(10)

Example: 1148032537

And then use: [user.last_active;frm='ddxx mmm yyyy hh:nn'] to format the date and time. However, all I'm getting is 01st Jan 1970 01:00

Can anyone shed any light on what might be going wrong?
By: TomH
Date: 2006-05-19
Time: 13:31

Re: Date Timr Format Issues in 3.0

Looks like you're raw data is in "unix timestamp" format.

My impression (tested) is that the TBS "frm=" assumes a "Date/Time" format which looks like "2006-02-24 09:35:10"   This is a native MySQL data format -- so you could translate the unix-time-stamp frmat directly to the "Date/Time" format in your database. 

Or you could us an ondata function to translate the data ;-(
By: Maz
Date: 2006-05-19
Time: 16:45

Re: Date Timr Format Issues in 3.0

I think you're right but this worked in previous versions of TBS, so I'm not convinced that it's by design yet.
By: Skrol29
Date: 2006-05-19
Time: 16:57

Re: Date Timr Format Issues in 3.0

Hi,

Unix timestamps should be accepted by parameter "frm" with TBS 3.0 like it was for 2.x. I've tried your tag with a var fiels and it works for me (TBS 3.0.4).

PHP:
$x = 1148032537;
HTML:
[var.x;frm='ddxx mmm yyyy hh:nn']
Result:
19th May 2006 11:55

Maybe your data item is not what you think.
By: Maz
Date: 2006-05-19
Time: 22:50

Re: Date Timr Format Issues in 3.0

I've tested the data item, and I'm 100% positive that it is holding the correct value. Maybe a strange question, but what version of mySQL did you test it on?
By: Skrol29
Date: 2006-05-20
Time: 00:36

Re: Date Timr Format Issues in 3.0

Hi,

I've not tested it with MySQL, only pure PHP. But your MySQL data shoud be converted as a PHP typed value anyway. Maybe the value is not what you believe. For instance, if it's a string with spaces then it won't fit.

Could you send to me the MySQL that will rebuild you table and the record that makes the problem ?
By: Maz
Date: 2006-05-20
Time: 08:22

Re: Date Timr Format Issues in 3.0

Will do
By: Maz
Date: 2006-05-20
Time: 10:30

Re: Date Timr Format Issues in 3.0

Oddly, this seems related to PHP5; here's why...

I've just noticed that the exact same issues arises on my existing site too, but it was fine before last weekend. The ONLY thing that has changed is that our host upgraded to PHP5 over last weekend.

Our existing site uses the php4 version of TBS, while the site I'm currently developing uses the PHP5 version of TBS. The problem occurs in both.

Hope this helps...
By: Skrol29
Date: 2006-05-22
Time: 16:32

Re: Date Timr Format Issues in 3.0

Hi Maz,

Thanks for having send a snippet to reproduce the problem.

Since PHP 5.1.0, function strtotime() returns false instead of -1 for a bad date value. That's why TBS always found that , inside its formating process, the value was bad.

This bug is fixed now and TBS 3.0.5 is available for download.



By: Maz
Date: 2006-05-22
Time: 18:42

Re: Date Timr Format Issues in 3.0

reat support as always, Skrol. Thanks very much for resolving the issue.