Forum Moderators: open

Message Too Old, No Replies

How do I input date of user submit?

         

wardy83

8:58 am on Aug 6, 2008 (gmt 0)

10+ Year Member



Hello!

I have a php form which users fill out and I would like a timestamp input in the database so I know when it was input.

I have REMOTE_ADDR to collect the IP address....what do I use to find time & date?

I already used REQUEST_TIME but it gives back a funny number like : 1218013726

Many thanks!

coopster

1:55 pm on Aug 6, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



That number is a UNIX timestamp which is the number of seconds past since the equinox, 1970-01-01. I personally prefer storing DATETIME values in ISO format.

SQL standards allow you to use values such as CURRENT_DATE, CURRENT_TIME and CURRENT_TIMESTAMP. The value is pulled from your server.

wardy83

2:02 pm on Aug 6, 2008 (gmt 0)

10+ Year Member



Cheers coop but I have figured it out ....

date_default_timezone_set('GMT+1');

$date = date('M jS Y H:i');

just used these variables and then used $date to output to email and into a mysql field.

rocknbil

5:48 pm on Aug 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



into a mysql field

There's a more efficient way with mysql. :-)

insert into table (timestamp) values (now());

now() is a combo date AND time stamp.

2008-08-06 10:47:48

It's also a good field to rely on for sorting by date/time. The field must be a datetime type.

eeek

4:11 am on Aug 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



insert into table (timestamp) values (now());

Wouldn't it be even easier to set a default value for the column and not mention it in the insert?