PigsHidePies Posted September 14, 2006 Share Posted September 14, 2006 Can I use the basic date() function and just put the value in a mysql database? I read that php and mysql interpret dates differently...also, how many chars should the database be...8? Thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/20716-how-to-store-date-in-mysql-database/ Share on other sites More sharing options...
wildteen88 Posted September 14, 2006 Share Posted September 14, 2006 When I deal with dates I prefer to use a unix timestamp (number secounds since Jan 1st 1970), I grab the timestamp using the time() function, then use an INT value and give it a max length of 20 or so.When I retrieve the date I use the date function to convert the timestamp into a readable date, using the secound parameter of the date functions.[code=php:0]date("D-m-y", $row['timestamp']);[/code]If you wnat to use the date function, then you'll wenat to use a VARCHAR field set to 255 chars. Quote Link to comment https://forums.phpfreaks.com/topic/20716-how-to-store-date-in-mysql-database/#findComment-91652 Share on other sites More sharing options...
PigsHidePies Posted September 14, 2006 Author Share Posted September 14, 2006 Thanks for the help, I used a char field of 24 chars and saved it in date('F jS Y') format...out of curiousity..why should it be 255 chars long? Quote Link to comment https://forums.phpfreaks.com/topic/20716-how-to-store-date-in-mysql-database/#findComment-91659 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.