dimanche 8 avril 2018

PHP - Get next draw date (Lottery)

I am planning to make a lottery with PHP. Now I want to output the next draw date with PHP.

The draw should start every Thuesday and thursday at 7 PM, and now I want to output the next draw date for the client:

Monday,Friday,Saturday,Sunday - Next draw date is Thuesday

Thuesday - Next draw date is Thuesday (today) if it is not 7 PM otherwise the next draw date is thursday.

Wednesday - Next draw date is the thursday

thursday - Next draw date is thursday (today) if it is not 7 PM otherwise the next draw date is Thuesday .

Now I want to create an if-Statement which prints out the correct date for every condition - for example for Wednesday the next date for Thursday and so on.

I really tried it serveral times but it is always a mess and not working.

Edit: Is it working like that?

 if(date('D') == "Tue" && new DateTime() < new DateTime("19:00:00")){
    //Dienstag
    return date('F j , Y');

}elseif(date('D') == "Tue" && new DateTime() > new DateTime("19:00:00")){
    //Donnerstag
    return date('F j , Y', strtotime('next thursday'));


}elseif(date('D') == "Thu" && new DateTime() < new DateTime("19:00:00")){
    //Donnerstag
    return date('F j , Y');

}elseif(date('D') == "Thu" && new DateTime() > new DateTime("19:00:00")){
    //Donnerstag
    return date('F j , Y', strtotime('next tuesday'));



}elseif(date('D') == 'Mon' || date('D') == 'Fri' || date('D') == 'Sat' || date('D') == 'Sun') {
    //Dienstag
    return date('F j , Y', strtotime('next tuesday'));


} elseif(date('D') == 'Wed') {
    //Donnerstag
    return date('F j , Y', strtotime('next thursday'));
}

Aucun commentaire:

Enregistrer un commentaire