Lodius2000 Posted May 31, 2008 Share Posted May 31, 2008 So here is a whole slew of questions I creating a cms, blog style, on my entry creation page I have created a series of select menus that allow me to set a time of creation for the current entry, problem is i cant figure out how to input it into the database so that I can get it back out and parse different parts of it at different places i.e. my entry when displayed on my index.html will say 'Posted at "time(including am or pm)" on "day", "month" "date", "year".' so my first question is, would I be better off using a mix of INT and VARCHAR fields in my DB table or should I use DATETIME, or TIMESTAMP, or DATE and TIME? second, if I use mktime() is there a reverse mktime() to convert the seconds back to a date for retrieval, and if i use mktime() what type of MySQL field do I use, INT, or is there one I am not seeing with my handy dandy MySQL cheat sheet? thanks so much for your help Link to comment https://forums.phpfreaks.com/topic/108086-storing-time-in-a-database/ Share on other sites More sharing options...
Barand Posted May 31, 2008 Share Posted May 31, 2008 I'd use a DATETIME fields and write NOW() to it when the record is inserted. When displaying you can use either DATE_FORMAT() in the query or format it in PHP with the date() function Link to comment https://forums.phpfreaks.com/topic/108086-storing-time-in-a-database/#findComment-554093 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.