ohdang888 Posted January 21, 2008 Share Posted January 21, 2008 when a row is inserted into the datase, there is a column that i want to make it automatically store the date and time it was inserted. so i used datetime on the TYPE option... but everything is coming up as 0000-00-00 00:00:00 do i need to use a datetime code in the script too? what it is if i do? Link to comment https://forums.phpfreaks.com/topic/87125-date-time/ Share on other sites More sharing options...
Daniel0 Posted January 21, 2008 Share Posted January 21, 2008 I'm not sure if it's possible, but you could try to set the default to NOW(). Otherwise explicitly make the date that. Link to comment https://forums.phpfreaks.com/topic/87125-date-time/#findComment-445572 Share on other sites More sharing options...
ohdang888 Posted January 21, 2008 Author Share Posted January 21, 2008 how do i use "now()"???? like.... $datetime = function(now()) ???? Link to comment https://forums.phpfreaks.com/topic/87125-date-time/#findComment-445573 Share on other sites More sharing options...
mike177 Posted January 22, 2008 Share Posted January 22, 2008 how do i use "now()"???? like.... $datetime = function(now()) ???? I'm not expert ohdang888 but thats not how you would use it. You need to give the function a name first then you () then {} to open and close. Link to comment https://forums.phpfreaks.com/topic/87125-date-time/#findComment-445669 Share on other sites More sharing options...
TheFilmGod Posted January 22, 2008 Share Posted January 22, 2008 no I believe the now() function is used in the actual mysql column. So when creating your mysql table you setup the column type to time stamp and then have a function in it saying now(). I think that makes sense! Link to comment https://forums.phpfreaks.com/topic/87125-date-time/#findComment-445670 Share on other sites More sharing options...
teng84 Posted January 22, 2008 Share Posted January 22, 2008 Ohdang!!! this is double post !!!! :-\ I want to add something on this thread because i believe I know the problem but I'm confused where to place my post should i post it here or in your second post.. Link to comment https://forums.phpfreaks.com/topic/87125-date-time/#findComment-445673 Share on other sites More sharing options...
Daniel0 Posted January 22, 2008 Share Posted January 22, 2008 no I believe the now() function is used in the actual mysql column. So when creating your mysql table you setup the column type to time stamp and then have a function in it saying now(). I think that makes sense! Yes, NOW() is a MySQL function. See: http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_now Link to comment https://forums.phpfreaks.com/topic/87125-date-time/#findComment-445866 Share on other sites More sharing options...
beebum Posted January 22, 2008 Share Posted January 22, 2008 CREATE TABLE mytable ( ...column_defs_here DT_inserted timestamp NOT NULL default CURRENT_TIMESTAMP, ...any_other_defs_here ); INSERT INTO mytable (col1, col2...) values ('col1val', 'col2val',...); Do not insert values for "DT_inserted" column or for an auto_increment column, these will be inserted automatically. Link to comment https://forums.phpfreaks.com/topic/87125-date-time/#findComment-446276 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.