Page 1 of 1

automatic date and time in news posts

Posted: Mon Jul 15, 2002 4:21 pm
by mike
hi I am using a mixture of phpmyadmin and mysqlfront to make my databases and tables in......

is their anyway of getting php to actually record into the database what time a record was entered into it-- for example I am using php mainly for news entry onto a basic web site-- this is working fine.. but what I want is for when I press submit on the news entry form for it to record the time and date into the database table and THEN be able to show this time and date in the news topic...

all help much appreciated

MIKE

Posted: Mon Jul 15, 2002 8:28 pm
by DSM
This might be a place to start

http://www.php.net/manual/en/ref.datetime.php

Posted: Tue Jul 16, 2002 2:47 pm
by haagen
Depending on what type of field you want to store the time / date into you can use one of the following mysql function: CURRENT_TIME, CURRENT_DATE, CURENT_TIMESTAMP. So a sql insert string might look like this:

insert into table (date, name, message) values (CURRENT_DATE, "haagen", "Hello world!");

My date field has the type "date".

When you read the field you can handle it as a text string. If you don't like the format mysql gives you try to format it with the mysql functions: DATE_FORMAT(date, format) and TIME_FORMAT(time, format).

Please look in the mysql manual for more info.