Snooble Posted December 5, 2008 Share Posted December 5, 2008 I have a sql table... NUMBER DATE I insert, "5", "" I need the date of the insert to be put in. example: 21-5-2008 Is it possible to get SQL to datestamp it automatically? or should i generate the date in PHP and save it too? Snoobs Quote Link to comment https://forums.phpfreaks.com/topic/135674-solved-timestamp-datestamp-mysql/ Share on other sites More sharing options...
JonnoTheDev Posted December 5, 2008 Share Posted December 5, 2008 yes INSERT INTO table SET datefield=CURDATE() Quote Link to comment https://forums.phpfreaks.com/topic/135674-solved-timestamp-datestamp-mysql/#findComment-706861 Share on other sites More sharing options...
gevans Posted December 5, 2008 Share Posted December 5, 2008 Your best option is to use he linux timestamp time() //in php script or MYSQL functions, TIMEDATE() link Quote Link to comment https://forums.phpfreaks.com/topic/135674-solved-timestamp-datestamp-mysql/#findComment-706862 Share on other sites More sharing options...
Mchl Posted December 5, 2008 Share Posted December 5, 2008 Use TIMESTAMP DEFAULT CURRENT_TIMESTAMP Quote Link to comment https://forums.phpfreaks.com/topic/135674-solved-timestamp-datestamp-mysql/#findComment-706866 Share on other sites More sharing options...
Snooble Posted December 5, 2008 Author Share Posted December 5, 2008 So i alter the database? what type? and i need it to be DD-MM-YYYY. Snoobs Quote Link to comment https://forums.phpfreaks.com/topic/135674-solved-timestamp-datestamp-mysql/#findComment-706871 Share on other sites More sharing options...
Mchl Posted December 5, 2008 Share Posted December 5, 2008 So i alter the database? what type? and i need it to be DD-MM-YYYY. Snoobs Read here about TIMESTAMP And no. You don't need it to be DD-MM-YYYY. You need to store it as a proper time format and be able to easily convert it to and from DD-MM-YYYY. Quote Link to comment https://forums.phpfreaks.com/topic/135674-solved-timestamp-datestamp-mysql/#findComment-706873 Share on other sites More sharing options...
Snooble Posted December 5, 2008 Author Share Posted December 5, 2008 thank you.. SOLVED Quote Link to comment https://forums.phpfreaks.com/topic/135674-solved-timestamp-datestamp-mysql/#findComment-706896 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.