Jump to content

divinedesigns1

Recommended Posts

hello, i am wonder how to create a timestamp, so when you insert something into the database it have a timestamp on it automatically, i try using this function UNIX_TIMESTAMP() but when i create a insert something into the db from a form it just give the column where the timestamp is located a value of 0 how do i make it have the timestamp?

Edited by DDs1
Link to comment
Share on other sites

Thanks for the reply, but i just made a mistake which i notice, i put the UNIX_TIMESTAMP() function in quotes, within the query so because of that it didnt work the first timeso my query was looking like this at first "INSERT INTO cakes VALUES('', '" . $_SESSION['uid'] . "', 'UNIX_TIMESTAMP()', '$al_name', '$al_desc')" so by remove the single quotes it is now looking like this "INSERT INTO cakes VALUES('', '" . $_SESSION['uid'] . "', UNIX_TIMESTAMP(), '$al_name', '$al_desc')" which end up working now :) thanks for the replies tho

Link to comment
Share on other sites

create a column in database with the field type "timestamp" it have a timestamp on it automatically when a new row inserted or updated an exited one
new knowledge thanks
Link to comment
Share on other sites

I prefer to have a column of type INT and store the Unix timestamp for manipulation with PHP.
yes thats what i did, i have a table with a type of int(11) and then i use the unix timestamp, but i made a mistake and put it in quotes
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...