twilightnights Posted January 27, 2007 Share Posted January 27, 2007 I have a submittal form and I want to append a time when it was submitted. I would also be able to make a query and sort by time so I can show newest on my web page. Can anyone help help me with this? Link to comment https://forums.phpfreaks.com/topic/35998-easiest-way-to-append-a-time-to-a-submittal-via-php-to-mysql/ Share on other sites More sharing options...
shocker-z Posted January 27, 2007 Share Posted January 27, 2007 just create a TIME field in your database and when inserting into the database use CURTIME() in the SQLand to order when retreiving the data append "SORT BY timefield ASC" to your queryRegardsLiam Link to comment https://forums.phpfreaks.com/topic/35998-easiest-way-to-append-a-time-to-a-submittal-via-php-to-mysql/#findComment-170757 Share on other sites More sharing options...
pocobueno1388 Posted January 27, 2007 Share Posted January 27, 2007 You could use a DATETIME field.To insert the time in the database you would use NOW()ex:[code]INSERT INTO table (time) VALUES ( NOW()));[/code]If you just used a time field and sorted by the time it was submitted, I would think it would get all mixed up the next day beacause it doesn't know the date it was submitted as well. Link to comment https://forums.phpfreaks.com/topic/35998-easiest-way-to-append-a-time-to-a-submittal-via-php-to-mysql/#findComment-170758 Share on other sites More sharing options...
twilightnights Posted January 27, 2007 Author Share Posted January 27, 2007 does curtime include date, month, year, etc? Or do you have to make seperate fields for each of these. Not exactly sure how searching would work with this.. for example 12232005 is greater mathematically to 09232006 Link to comment https://forums.phpfreaks.com/topic/35998-easiest-way-to-append-a-time-to-a-submittal-via-php-to-mysql/#findComment-170761 Share on other sites More sharing options...
twilightnights Posted January 27, 2007 Author Share Posted January 27, 2007 Also what datatype should I use in the mysql database, just store is as an int? there are a bunch of date/time things it seems a little confusing on how it would work with the php code. Link to comment https://forums.phpfreaks.com/topic/35998-easiest-way-to-append-a-time-to-a-submittal-via-php-to-mysql/#findComment-170766 Share on other sites More sharing options...
pocobueno1388 Posted January 27, 2007 Share Posted January 27, 2007 DATETIME includes the date/month/year and time if that is what you want. In the database you would just store the field under DATETIME. Link to comment https://forums.phpfreaks.com/topic/35998-easiest-way-to-append-a-time-to-a-submittal-via-php-to-mysql/#findComment-170767 Share on other sites More sharing options...
twilightnights Posted January 27, 2007 Author Share Posted January 27, 2007 oh thanks a lot, I complete missed that you said above to make it a date time field. Worked like a charm, ty. Link to comment https://forums.phpfreaks.com/topic/35998-easiest-way-to-append-a-time-to-a-submittal-via-php-to-mysql/#findComment-170774 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.