How to DESC
order Date
field in while loop How to DESC
order Date
field by using while loop select data First We need ASC ORDER & After We need Display DESC ORDER Date
$start_date="SELECT user_registered FROM wp_users ORDER BY user_registered ASC LIMIT 1";
$date_result=$wpdb->get_results($start_date) or die(mysqli_error());
$date = date('Y-m-d',strtotime($date_result[0]->user_registered));
$end_date = date('Y-m-d');
while ($end_date >= $date)
{
echo $date;
$date = date("Y-m-d", strtotime("+1 day", strtotime($date)));
}
we need desc order echo $date
I think you may use like below .
$array = array();
while ($end_date >= $date) {
$array[]=$date;
$date = date("Y-m-d", strtotime("+1 day", strtotime($date)));
}
echo '<pre/>';
print_r(array_reverse($array));
Try this:
while( $end_date >= $date )
{
echo $end_date;
$end_date = date("Y-m-d", strtotime("-1 day", strtotime( $end_date ) ) );
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.