I am trying to write a php program that stores a date in an SQL database. Since I need to have the dates sorted, I decided to use a unix timestamp to represent the date. I cannot seem to write an arbitrary timestamp from a past date into the database. If I define the field in the database table as:
Thread timestamp DEFAULT 0,
it initializes the field to 0 (naturally) and I cannot change the field to any other value. A statement like:
$uxstamp = strtotime(‘Ascii date string’);
mysql_query(“UPDATE Topics SET Thread=$uxstamp WHERE TID=$tkey”);
does not change the value in the field.
If I define the field in the database with
Thread timestamp NOT NULL,
The SQL interpreter forces the “update with current timestamp” attribute, and I get the current date, not what I write. Can I not change timestamp once it is in the database? How can I set up a date/time field in the database so that it is easily sortable by date?