acctman Posted November 2, 2008 Share Posted November 2, 2008 this is the format I want displayed, Wednesday, 11/02/2008 : 1:22pm how would I display and save that to mysql insert and retrieve Quote Link to comment https://forums.phpfreaks.com/topic/131100-solved-saving-and-displaying-date-phpmysql/ Share on other sites More sharing options...
Andy-H Posted November 2, 2008 Share Posted November 2, 2008 $date = date('l, d/m/Y : g:ia'); Quote Link to comment https://forums.phpfreaks.com/topic/131100-solved-saving-and-displaying-date-phpmysql/#findComment-680654 Share on other sites More sharing options...
acctman Posted November 2, 2008 Author Share Posted November 2, 2008 $date = date('l, d/m/Y : g:ia'); when saving to mysql should i just setup a tinytext field and store the $date var ? Quote Link to comment https://forums.phpfreaks.com/topic/131100-solved-saving-and-displaying-date-phpmysql/#findComment-680660 Share on other sites More sharing options...
Andy-H Posted November 2, 2008 Share Posted November 2, 2008 I just usually use varchar(255), tinytext will work all the same tho... Quote Link to comment https://forums.phpfreaks.com/topic/131100-solved-saving-and-displaying-date-phpmysql/#findComment-680669 Share on other sites More sharing options...
bobbinsbro Posted November 2, 2008 Share Posted November 2, 2008 but the length of that date format will never be longer than 32 bytes... why use 255? Quote Link to comment https://forums.phpfreaks.com/topic/131100-solved-saving-and-displaying-date-phpmysql/#findComment-680678 Share on other sites More sharing options...
Andy-H Posted November 2, 2008 Share Posted November 2, 2008 Because I'm wastefull on resources and have never looked into sorting this out. Quote Link to comment https://forums.phpfreaks.com/topic/131100-solved-saving-and-displaying-date-phpmysql/#findComment-680679 Share on other sites More sharing options...
kenrbnsn Posted November 2, 2008 Share Posted November 2, 2008 Don't store a date in a varchar field. You won't be able to use the very powerful date functions in mysql. Use either a date or datetime field and store it as YYYY-MM-DD HH:MM:SS. Use date() and strtotime() when you display the date/time. Or use MySQL to format the string. Ken Quote Link to comment https://forums.phpfreaks.com/topic/131100-solved-saving-and-displaying-date-phpmysql/#findComment-680687 Share on other sites More sharing options...
bobbinsbro Posted November 2, 2008 Share Posted November 2, 2008 @Andy-H: Quote Link to comment https://forums.phpfreaks.com/topic/131100-solved-saving-and-displaying-date-phpmysql/#findComment-680693 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.