Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with php date
    primarykey
    data
    text
    <p>I've run into a bit of trouble with the PHP date function (I have almost 0 knowledge when it comes to this).</p> <p>I want to get the next 5 days of the week saved in 3 parameter like variables such as <code>$month</code>, <code>$dayofmonth</code> and <code>$dayofweek</code> and having it displayed June 4 Tuesday, each part of the date to be able to be put inside its coresponding html div elements.</p> <p>I've experimented for the last 2 days with different codes but none worked and 3 hours ago I came to the conclusion that the way I was getting the month, I would have a conflict at the end of the month, because the name changes. So I would have had May 31 Friday, May 1 Saturday, May 2 Sunday etc.</p> <p>What i have for now, i think i've corrected the problem with end of the month.</p> <pre><code>$month = date("F"); $day_1 = date("j"); $day_2 = date("j", strtotime("+1 days")); $day_3 = date("j", strtotime("+2 days")); $day_4 = date("j", strtotime("+3 days")); $day_5 = date("j", strtotime("+4 days")); $wday_1 = date("l"); $wday_2 = date("l", strtotime("+1 weekday")); $wday_3 = date("l", strtotime("+1 weekday")); $wday_4 = date("l", strtotime("+1 weekday")); $wday_5 = date("l", strtotime("+1 weekday")); $next_month = date("F", strtotime("+1 month")); echo $day_1." ".$wday_1." "; if($day_1 == 28 || $day_1 == 29 || $day_1 == 30 || $day_1 == 31 || $day_2 == 28 || $day_2 == 29 || $day_2 == 30 || $day_2 == 31 || $day_3 == 28 || $day_3 == 29 || $day_3 == 30 || $day_3 == 31 || $day_4 == 28 || $day_4 == 29 || $day_4 == 30 || $day_4 == 31 || $day_5 == 28 || $day_5 == 29 || $day_5 == 30 || $day_5 == 31) { $month = $next_month; } echo $month; </code></pre> <p>I have read the documentation about date but i need every part of the date in a different variable that can be easily used in localisation changes and SQL selects.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload