Page 1 of 1

hot to insert a UNIX_TIMESTAMP in a field with an ADDT form?

Posted: 2011-07-29 10:01
by antonio
Hi all,
I'm just getting crazy trying to insert a UNIX_TIMESTAMP in a field using an ADDT form.
I use php4 and mysql 4, and I tried all combination in phpmyadmin for the date field of my table but without success.
I need to store a UNIX_TIMESTAMP in a field so that I can use it with my RSS feed.

The only way to get a UNIX_TIMESTAMP value in a field has been (for me) to set the date field to INT(10) and then editing the record in phpmyadmin and changing the FUNCTION for the date field to UNIX_TIMESTAMP.

But I cannot edit all records (ugh!) manually every time I add a record.

Is there a way to get a UNIX_TIMESTAMP in a table using ADDT or Kollection pro?

TIA

tony

Re: hot to insert a UNIX_TIMESTAMP in a field with an ADDT f

Posted: 2011-07-29 17:30
by antonio
SOLVED: I have put

Code: Select all

time()
as default in the dynamic form and set the field in phpmyadmin as INT (10).

I changed the update transaction too, just to update the unix timestamp when updating the record, so I've put

Code: Select all

time()
as default of the date field even to the update transaction

HTH

tony

Re: hot to insert a UNIX_TIMESTAMP in a field with an ADDT f

Posted: 2011-08-04 16:28
by Fred
What you can do to automate the process without any input required from your update form is to set the fieldtype like in the example on the mysql documentation;

Code: Select all

CREATE TABLE t (ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
                             ON UPDATE CURRENT_TIMESTAMP);
CREATE TABLE t (ts TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
                             DEFAULT CURRENT_TIMESTAMP);
This will probably only work with mysql version 4.1 or later.

IStill running on php 4 and mysql 4?
I would seriously suggest you upgrade... You are going to get hacked!!