soltek Posted July 21, 2010 Share Posted July 21, 2010 Hey there The following code prints the number of posts added on the last 24 hours and I wanted to make it so it prints the posts whoose ADDED value in the database is equal to the current day, month and year. Here's the code: $date_time = get_date_time(gmtime()-(3600*24)); // the 24hrs $todaypos = number_format(get_row_count("posts", "WHERE posts.added>='$date_time'")); echo "<br>Today's posts:<B> " . $todaypos . "</b>"; If you could give me a hand, it'd be awesome, Thank you. Link to comment https://forums.phpfreaks.com/topic/208440-get_date_time-select-only-day-month-and-year/ Share on other sites More sharing options...
AbraCadaver Posted July 21, 2010 Share Posted July 21, 2010 This should do it: $date = date('Ymd'); $todaypos = number_format(get_row_count("posts", "WHERE DATE_FORMAT(posts.added, '%Y%m%d') = '$date'")); EDIT: wrong var in query. Use DATE_FORMAT, not DATE Link to comment https://forums.phpfreaks.com/topic/208440-get_date_time-select-only-day-month-and-year/#findComment-1089201 Share on other sites More sharing options...
soltek Posted July 21, 2010 Author Share Posted July 21, 2010 I was so simple. Thank you, AbraCadaver Link to comment https://forums.phpfreaks.com/topic/208440-get_date_time-select-only-day-month-and-year/#findComment-1089224 Share on other sites More sharing options...
soltek Posted July 22, 2010 Author Share Posted July 22, 2010 And how can I select the ones of the current month? Link to comment https://forums.phpfreaks.com/topic/208440-get_date_time-select-only-day-month-and-year/#findComment-1089364 Share on other sites More sharing options...
BillyBoB Posted July 22, 2010 Share Posted July 22, 2010 Just remove the day. $date = date('Ym'); $todaypos = number_format(get_row_count("posts", "WHERE DATE_FORMAT(posts.added, '%Y%m') = '$date'")); Link to comment https://forums.phpfreaks.com/topic/208440-get_date_time-select-only-day-month-and-year/#findComment-1089372 Share on other sites More sharing options...
AbraCadaver Posted July 22, 2010 Share Posted July 22, 2010 Just remove the day. $date = date('Ym'); $todaypos = number_format(get_row_count("posts", "WHERE DATE_FORMAT(posts.added, '%Y%m') = '$date'")); Yes, read and try and come up with something on your own:-* Link to comment https://forums.phpfreaks.com/topic/208440-get_date_time-select-only-day-month-and-year/#findComment-1089384 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.