limitphp Posted April 15, 2009 Share Posted April 15, 2009 I am building a page that will be used to add songs to my website. It will have songName, Genre, and copyrightDate copyright Date is a datetime field. How would I enter it in a textbox? Do I have to include the time? The reason it is a datetime field is because I know how to do searches on that type of field based on dates.... Link to comment https://forums.phpfreaks.com/topic/154234-solved-what-to-enter-for-datetime-field/ Share on other sites More sharing options...
Mchl Posted April 15, 2009 Share Posted April 15, 2009 First, if it is only for dates, use DATE instead of DATETIME. YOu save 4 bytes per row. Second: MySQL's datetime format is YYYYMMDDHHMMSS, you can use just about any separators with that, for example YYYY-MM-DD HH:MM:SS Third: You can actually use any format you like, provided that your script will transform it to MySQL compatible format before inserting. Link to comment https://forums.phpfreaks.com/topic/154234-solved-what-to-enter-for-datetime-field/#findComment-810845 Share on other sites More sharing options...
CloudSex13 Posted April 15, 2009 Share Posted April 15, 2009 Use <select> and <option> fields with predefined values for month, day, year, hour, minute, and second. Or you could just do the date field, and keep it simple. Link to comment https://forums.phpfreaks.com/topic/154234-solved-what-to-enter-for-datetime-field/#findComment-810885 Share on other sites More sharing options...
limitphp Posted April 15, 2009 Author Share Posted April 15, 2009 First, if it is only for dates, use DATE instead of DATETIME. YOu save 4 bytes per row. Second: MySQL's datetime format is YYYYMMDDHHMMSS, you can use just about any separators with that, for example YYYY-MM-DD HH:MM:SS Third: You can actually use any format you like, provided that your script will transform it to MySQL compatible format before inserting. If I change it to DATE, can i still do this: WHERE date > NOW()-INTERVAL 7 DAY Link to comment https://forums.phpfreaks.com/topic/154234-solved-what-to-enter-for-datetime-field/#findComment-810903 Share on other sites More sharing options...
Mchl Posted April 15, 2009 Share Posted April 15, 2009 You would use CURDATE() rather than NOW() Link to comment https://forums.phpfreaks.com/topic/154234-solved-what-to-enter-for-datetime-field/#findComment-810910 Share on other sites More sharing options...
limitphp Posted April 15, 2009 Author Share Posted April 15, 2009 You would use CURDATE() rather than NOW() other than that it would be exactly the same? still use -INTERVAL x DAY? Link to comment https://forums.phpfreaks.com/topic/154234-solved-what-to-enter-for-datetime-field/#findComment-810916 Share on other sites More sharing options...
Mchl Posted April 15, 2009 Share Posted April 15, 2009 Yeah. You can try by yourself. Just run SELECT CURDATE() - INTERVAL 7 DAY in your MySQL console Link to comment https://forums.phpfreaks.com/topic/154234-solved-what-to-enter-for-datetime-field/#findComment-810920 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.