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

Any tips and tricks that has to with the ADDT that doesn't fit into one of the other categories
antonio
Posts: 77
Joined: 2010-09-28 11:48

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

Post by antonio » 2011-07-29 10:01

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

antonio
Posts: 77
Joined: 2010-09-28 11:48

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

Post by antonio » 2011-07-29 17:30

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

User avatar
Fred
Site Admin
Posts: 491
Joined: 2010-02-15 12:10
Location: Armagh, Northern Ireland
Contact:

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

Post by Fred » 2011-08-04 16:28

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!!

Post Reply