divinedesigns1 Posted August 1, 2012 Share Posted August 1, 2012 (edited) 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 August 1, 2012 by DDs1 Link to comment Share on other sites More sharing options...
birbal Posted August 1, 2012 Share Posted August 1, 2012 you can post the query you are using. there is also a php function for that http://php.net/time 1 Link to comment Share on other sites More sharing options...
php_developer Posted August 1, 2012 Share Posted August 1, 2012 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 Link to comment Share on other sites More sharing options...
divinedesigns1 Posted August 1, 2012 Author Share Posted August 1, 2012 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 More sharing options...
divinedesigns1 Posted August 1, 2012 Author Share Posted August 1, 2012 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 onenew knowledge thanks Link to comment Share on other sites More sharing options...
Ingolme Posted August 1, 2012 Share Posted August 1, 2012 I prefer to have a column of type INT and store the Unix timestamp for manipulation with PHP. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted August 1, 2012 Author Share Posted August 1, 2012 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 More sharing options...
kanchatchai Posted August 6, 2012 Share Posted August 6, 2012 strtotime("now") Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now