OriginalBoy Posted September 27, 2008 Share Posted September 27, 2008 Hello I am creating a new website and it involves a form which submits to a database. What I need it to do is find out the date and put that in the database. Then once this has done I need to select from the table sites and order it by date. Best Regards Steve Quote Link to comment https://forums.phpfreaks.com/topic/126090-date/ Share on other sites More sharing options...
Barand Posted September 27, 2008 Share Posted September 27, 2008 the mysql function CURDATE() gives the current date. eg INSERT INTO user (username, pwd, date_reg) VALUES ('$usr', '$pwd', CURDATE() ) If you want date and time, use NOW() instead of CURDATE() Quote Link to comment https://forums.phpfreaks.com/topic/126090-date/#findComment-652058 Share on other sites More sharing options...
OriginalBoy Posted September 28, 2008 Author Share Posted September 28, 2008 the mysql function CURDATE() gives the current date. eg INSERT INTO user (username, pwd, date_reg) VALUES ('$usr', '$pwd', CURDATE() ) If you want date and time, use NOW() instead of CURDATE() How would I sort it by the date and time and also what mysql type would I use to add this data in. Quote Link to comment https://forums.phpfreaks.com/topic/126090-date/#findComment-652349 Share on other sites More sharing options...
Barand Posted September 28, 2008 Share Posted September 28, 2008 Use DATE or DATETIME column type. Sort as any other column, eg ... ORDER BY date_reg Quote Link to comment https://forums.phpfreaks.com/topic/126090-date/#findComment-652410 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.