Forums

PHP

This topic is locked

Phakt error applying a date format to a date field

Posted 18 Oct 2001 01:11:57
1
has voted
18 Oct 2001 01:11:57 Sebastian Veggiani posted:
Hi! First, I'm posting this bug here because Phakt Bugtracker seems to be out of service.

(Phakt 1.0.6)
When I apply a date format to a Dynamic Text causes the following error:

Warning: unexpected error in date() in c:/archivos de programa/merlin desktop/apache/htdocs/techlink/agro/tmp4gsgsldhbc.php on line 16

The field type in my MySQL table is 'timestamp'.
Can you help me please?
Thanks

Sebastian Veggiani



Edited by - elhobbit on 10/18/2001 01:14:18

Replies

Replied 18 Oct 2001 01:29:57
18 Oct 2001 01:29:57 Tim Green replied:
Please post the code from your page that is highlighted by the error message.

The problem here is very likely to do with Locale as the DoDateTime function presumes that your timestamp information is stored in the following format :-

9999-99-99 99:99:99

Where the nines indicate a numeric digit. However, without seeing the code that is causing you the problem, this is purely as guess.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 29 Nov 2001 01:34:35
29 Nov 2001 01:34:35 David McGuire replied:
I have also run into the same problem. If I don't apply date formatting, it works fine but comes up in MySQL format YYYY-DD-MM.
The error I'm getting is:
Warning: unexpected error in date() in c:\program files\apache group\apache\htdocs\sandbox\details.php on line 19
Line 19 is part of the PHP function for 'DoDateTime':
&lt;?php function DoDateTime($theObject, $NamedFormat) {
ereg("([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2})<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>[0-9]{2})<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>[0-9]{2})", $theObject, $tgRegs);
$parsedDate=date($NamedFormat, mktime($tgRegs[4],$tgRegs[5],$tgRegs[6],$tgRegs[2],$tgRegs[3],$tgRegs[1]));
return $parsedDate;
}
?&gt;
I have 2 date fields: startdate and enddate. They're both date fields and do not have the time thrown in.
I bet it's something about that regex, but I'm so bad at 'em that I can't tell.
Replied 29 Nov 2001 14:47:44
29 Nov 2001 14:47:44 Sebastian Veggiani replied:
I've still the same problem, I think I was the only that got this error, but the error looks exactly the same to the yours.
This error doesn't exists in Phakt 0.8.3 or 1.0.1

elhobbit

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I have also run into the same problem. If I don't apply date formatting, it works fine but comes up in MySQL format YYYY-DD-MM.
The error I'm getting is:
Warning: unexpected error in date() in c:\program files\apache group\apache\htdocs\sandbox\details.php on line 19
Line 19 is part of the PHP function for 'DoDateTime':
&lt;?php function DoDateTime($theObject, $NamedFormat) {
ereg("([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2})<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>[0-9]{2})<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>[0-9]{2})", $theObject, $tgRegs);
$parsedDate=date($NamedFormat, mktime($tgRegs[4],$tgRegs[5],$tgRegs[6],$tgRegs[2],$tgRegs[3],$tgRegs[1]));
return $parsedDate;
}
?&gt;
I have 2 date fields: startdate and enddate. They're both date fields and do not have the time thrown in.
I bet it's something about that regex, but I'm so bad at 'em that I can't tell.

<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Replied 05 Dec 2001 12:07:28
05 Dec 2001 12:07:28 Tim Green replied:
The DoDateTime function has not changed since it was first introduced, and therefore if this issue does not exist for you in other versions of PHAkT, then it is likely either a useage issue, or an ADODB issue.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 05 Dec 2001 13:07:48
05 Dec 2001 13:07:48 Bruno Mairlot replied:
Hi,

to adress this issue, I would strongly recommend that you'd use the MySQL built-in date and time function.

If you want to convert a timestamp into a date, then you can use :

year()
month()
dayofmonth()

then, in your query use the following :

<b>
SELECT ..., concat(dayofmonth(timestp),'/',month(timestp),'/',year(timestp)) as date,... FROM myTable
</b>

In this example I presumed that your Timestamp is called timestp, just change this according to your table info.

There are plenty of function to let you do, almost whatever you'd want.

Bruno

P.S. Manipulating date directly in MySQL is much quickier than in PHP (IMHO)


--- Better to die trying, than never try at all ---
Replied 07 Dec 2001 11:30:47
07 Dec 2001 11:30:47 Tim Green replied:
Rather than building this into your SQL query (which then makes it database dependant) you can use the ADODB functions DBDate() and DBTime(). To find more information on these functions consult the Readme.htm in your ADODB directory.

Using these functions will allow your code to become portable. Essentially what they do is to format your date according to the DB system that is being used.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 07 Dec 2001 13:42:57
07 Dec 2001 13:42:57 Bruno Mairlot replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Rather than building this into your SQL query (which then makes it database dependant) you can use the ADODB functions DBDate() and DBTime(). To find more information on these functions consult the Readme.htm in your ADODB directory.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Hehe, yes I agree, sorry I'm sometime too MySQL minded <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

But you're definitely right about it Tim!!

--- Better to die trying, than never try at all ---

Reply to this topic