dennismonsewicz Posted March 18, 2008 Share Posted March 18, 2008 Is there a way to create a current timestamp and record the timestamp into a database? Quote Link to comment Share on other sites More sharing options...
conker87 Posted March 18, 2008 Share Posted March 18, 2008 Look for date() in the manual. Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted March 18, 2008 Author Share Posted March 18, 2008 aight thanks will do Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 18, 2008 Share Posted March 18, 2008 if you want a timestamp, use time(). Most databases provide a field of type timestamp. In MySQL, simply set a field as timestamp and it will automatically update with each record insert/update. if you want to insert a timestamp into MySQL, you can use the MySQL NOW() function. Quote Link to comment Share on other sites More sharing options...
conker87 Posted March 18, 2008 Share Posted March 18, 2008 Can you convert the unix_timestamp into the current time/date (in DD-MM-YYYY HH:MM format)? And visa versa? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 18, 2008 Share Posted March 18, 2008 yes. the default second argument for date() is the current unix timestamp. strtotime() works well converting the other direction. Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted March 18, 2008 Author Share Posted March 18, 2008 Thanks for everyone's help! Quote Link to comment Share on other sites More sharing options...
conker87 Posted March 18, 2008 Share Posted March 18, 2008 Hmm, never knew that, I guess using time() would also save on db size.. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 18, 2008 Share Posted March 18, 2008 i don't know for sure, but my guess is that MySQL stores all dates and times in timestamp form but converts the timestamp to whatever field type is in use, e.g., date, date-time, time, etc. so i'm not sure changing a date field to a timestamp field would have any measurable effect. Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted March 18, 2008 Author Share Posted March 18, 2008 In setting up the field for the timestamp in MySQL do i need to tell the timestamp field to auto_increment or will it do it on its own? I am using PHPmyadmin Quote Link to comment Share on other sites More sharing options...
conker87 Posted March 18, 2008 Share Posted March 18, 2008 It'll be in one of the drop-down lists, I can't remember which one it ism but it's called 'ON UPDATE CURRENT TIMESTAMP'. Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted March 18, 2008 Author Share Posted March 18, 2008 Found it! Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.