Baseball Posted December 24, 2009 Share Posted December 24, 2009 to hold a variable like this "Thursday January 20th 2010" should i ust varchar? or does it really matter? Quote Link to comment https://forums.phpfreaks.com/topic/186256-whats-the-best-data-type-mysql/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 24, 2009 Share Posted December 24, 2009 Use a DATE data type. To get your existing format into a DATE type, use the mysql STR_TO_DATE() function in your query. Quote Link to comment https://forums.phpfreaks.com/topic/186256-whats-the-best-data-type-mysql/#findComment-983675 Share on other sites More sharing options...
Baseball Posted December 24, 2009 Author Share Posted December 24, 2009 nt i will juse use $timestamp = Date(blabla) and insert it.. Quote Link to comment https://forums.phpfreaks.com/topic/186256-whats-the-best-data-type-mysql/#findComment-983688 Share on other sites More sharing options...
ChemicalBliss Posted December 24, 2009 Share Posted December 24, 2009 Use timestamp(); The fastest data types in mysql are the integers. use a big int. then to get the current date in a unix timestamp = time(); to get the date from a timestamp, use: date("format..",$timestamp); To convert a Formatted date to a timestamp use the strtotime($formatted_date) function. time() http://php.net/time strtotime() http://php.net/strtotime date http://php.net/date -CB- Quote Link to comment https://forums.phpfreaks.com/topic/186256-whats-the-best-data-type-mysql/#findComment-983691 Share on other sites More sharing options...
PFMaBiSmAd Posted December 24, 2009 Share Posted December 24, 2009 An integer may be the fastest choice for a data type, but the extra manipulation you must use to get a Unix Timestamp into and out of a usable format makes it the worst choice to use to store date/time information in a database. Quote Link to comment https://forums.phpfreaks.com/topic/186256-whats-the-best-data-type-mysql/#findComment-983698 Share on other sites More sharing options...
ChemicalBliss Posted December 24, 2009 Share Posted December 24, 2009 It's usable in it's current state, you only need to convert it if displayin or saving, in fact, it is much, much easier to doing time-comparison functions. unix timestamps are the preffered performance for fast conditional date/time statements. and it is much more accure, saves db space, and saves memory. -CB- Quote Link to comment https://forums.phpfreaks.com/topic/186256-whats-the-best-data-type-mysql/#findComment-983700 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.