Forums

PHP

This topic is locked

Auto adding date modified/User to table!? HELP

Posted 04 Mar 2002 21:26:26
1
has voted
04 Mar 2002 21:26:26 Kurt Melander posted:
Hi All,
using ImPakt/NeXTsion, been trying to implement that the Date an entry is added or updated and the user who modified it is inserted automatically into a record. I've tried various things tied to hidden form items for the date and nothing seems to work
<input type="hidden" name="NOW" value="<?php echo $v?>">
<pre id=code><font face=courier size=2 id=code>input type="hidden" name="NOW" value="?php echo $v?
input type="hidden" name="NOW" value="?php echo DoDateTime( $Recordset1-&gt;Fields("Last_modify", 'F jS Y g:ia')</font id=code></pre id=code>
(yes, I know the tag brackets are missing, this "Code" forum function doesn't seem to allow it. - something I'm doing wrong I'm sure)
and variations of "NOW()" but nothing...

Tried tying a session variable to a field, but was using MM_Username, after reading this forum, I guess I should have been using $KT_Username so I'll give that a try and see what happens.

But I really need this date thing to work as well.

I see that InterAKTs discussion board isn't as active, and this one seems much more helpful and timely.

Any help for a complete "Newbie" to UD and PHP sincerely appreciated.


Replies

Replied 04 Mar 2002 23:06:42
04 Mar 2002 23:06:42 Bruno Mairlot replied:
Kurtmel,

there is something ready to help you for this : The TIMESTAMP SQL field.

If your database support it, then, just define the date field as a timestamp. Then, just don't worry about it because, when the record is created or updated the SQL server will change it automatically for you.

This is a standard feature in most recent SQL server, so if you can't find how to use the timestamp just tell us which SQL server you're using.

In the case you're using MySQL, then the syntax is :

date timestamp (as is)

Bruno

--- Better to die trying, than never try at all ---
Replied 05 Mar 2002 02:28:35
05 Mar 2002 02:28:35 Kurt Melander replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Kurtmel,

there is something ready to help you for this : The TIMESTAMP SQL field.

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

Thanks Bruno,
Yes, that worked great. DUH!! Guess I have a major RTFM session due with the MySQL manual. BUT, now my question is, how can I "pretty" this up for displaying the record - I've tried the formating options under the ImPAKT DynamicPHP item in server behaviors but, when I do, it gives me a default date/time in the correct format, but its not displaying the actual timestamp from the records when listed.

But I'm getting closer - thank you!!



Replied 05 Mar 2002 09:45:48
05 Mar 2002 09:45:48 Bruno Mairlot replied:
You can always use the date formatting function of MySQL (presuming you're using MySQL).

These functions are year(),month(),dayofmonth(), hour(),minute()

For example, if you want to format a date like : DD/MM/YYYY, then I would use the select statement :

SELECT concat(dayofmonth(date),'/',month(date),'/',year(date)) as date, .... FROM ...

Of course you can always try to figure out exactly why the date formatting doesn't work to make your code more portable.

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

Reply to this topic