jagguy Posted March 22, 2007 Share Posted March 22, 2007 hi, I want to use php to display a table with data fields added over the past 4 weeks . This table has a field 'added' of type datetime( eg 2007-22-03 12:32:14) . How do i do this in php? select * from categories where products_date_added > (todays date - 4 weeks) Link to comment https://forums.phpfreaks.com/topic/43811-search-by-datetime/ Share on other sites More sharing options...
onlyican Posted March 22, 2007 Share Posted March 22, 2007 First you want to get what today - 4 weeks is <?php $LinuxToday = strtotime("now"); $ADay = 1*60 *60 *24; $Linux4WeeksAgo = $LinuxToday - 28 * $ADay; $DB4WeeksAgo = date("Y-m-d H:i:s", $Linux4WeeksAgo; $Today = date("Y-m-d H:i:s"); $query = "SELECT * FROM Categories WHERE ProductsDateAdded BETWEEN '".$DB4WeeksAgo."' AND '".$Today."'"; ?> Link to comment https://forums.phpfreaks.com/topic/43811-search-by-datetime/#findComment-212695 Share on other sites More sharing options...
jagguy Posted March 23, 2007 Author Share Posted March 23, 2007 thanks for the answer, i appreciate it. Do you happen to know how zenlink works in php? Link to comment https://forums.phpfreaks.com/topic/43811-search-by-datetime/#findComment-213361 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.