简体   繁体   中英

Get date of the day following week in php

I'm creating a appointment application in android and php patient can select appointments from the given list in android. The selected day will be send to server, and there appointments will shown in android fetched from server, time and date, time part is done, date part can't figure out how to get the date problem is current day is Tuesday(5-12-2017) and someone make an appointment for Friday(8-12-2017), how to get date of Friday And what if he makes and appointment for Monday(11-12-2017) cant figure out how to do this, I can get current day and date but how to increment to the user defined day to get the date in PHP

Here

$choice = "Tuesday";

$Date = new DateTime();
$Clone = clone $Date;

$Clone->modify($choice." this week");

if( $Date > $Clone ){
    $Clone = clone $Date;
    $Clone->modify($choice." next week");
}

print_r($Clone->format('Y-m-d'));

Outputs

2017-12-05

You can test it here

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM