Answers.Body: <blockquote>
    <p>Maybe it doesn't work because the monthyear variable is formed in dutch and not english? </p>
  </blockquote>
  
  <p>Yes that's part of the problem. Have a look at PHP's <a href="http://php.net/manual/en/datetime.formats.relative.php" rel="nofollow noreferrer">relative formats</a> page to see what it supports. </p>
  
  <p>You can actually pull off what you're doing with the <code>this</code> keyword.</p>
  
  <pre><code>{% set secondSunday = now|date_modify("second sunday of this month")%}
  {% set lastSunday = now|date_modify("last sunday of this month") %}
  </code></pre>
  
  <p>You also don't need to define (or override) <a href="https://craftcms.com/docs/templating/global-variables#now" rel="nofollow noreferrer"><code>now</code></a> since Craft will always set that to a DateTime object for you. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-06T19:04:45.623Z
Answers.Text: Awesome, thank you very much!
Answers.UserDisplayName: mdmngz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-05T21:05:52.400Z
Answers.LastActivityDate: 2017-06-05T21:05:52.400Z
Answers.UserDisplayName: RitterKnight
Body: <p>How can I check if today is the second or last sunday of this month?
  My effort:</p>
  
  <pre><code>{% set now = now|date('U') %}
  {% set monthyear = now|date('F Y') %}
  {% set secondSunday = now|date_modify("#{monthyear} second sunday")|date('U') %}
  {% set lastSunday = now|date_modify("#{monthyear} last sunday")|date('U') %}
  
  {# check if now is second or last sunday #}                    
  {% if now == secondSunday or now == lastSunday %}
     {# YES, today is the second or the last sunday #}
  {% else %}
     {# NOPE #}
  {% endif %
  </code></pre>
  
  <p>But I keep getting the following error:</p>
  
  <pre><code>DateTime::modify(): Failed to parse time string (juni 2017 second sunday) at position 0 (j): The timezone could not be found in the database
  </code></pre>
  
  <p><strong>Maybe it doesn't work because the monthyear variable is formed in dutch and not english? (juni = june) If this is the case, how can I modify this to english in order to get it to work?</strong></p>
  
  <p>Also, my timezone is correctly set to UTC+2 (CEST) - Europe/Brussels via Settings > General</p>
  
  <p>Thanks!</p>
  
Tags: <datetime>
Title: Check if we're the second or last sunday of the month today
ThreadText: # Check if we're the second or last sunday of the month today
  
  (Asked by: username_0 on 2017-06-05)
  
  How can I check if today is the second or last sunday of this month?
  My effort:
  
  ```
  {% set now = now|date('U') %}
  {% set monthyear = now|date('F Y') %}
  {% set secondSunday = now|date_modify("#{monthyear} second sunday")|date('U') %}
  {% set lastSunday = now|date_modify("#{monthyear} last sunday")|date('U') %}
  
  {# check if now is second or last sunday #}                    
  {% if now == secondSunday or now == lastSunday %}
     {# YES, today is the second or the last sunday #}
  {% else %}
     {# NOPE #}
  {% endif %
  
  ```
  
  But I keep getting the following error:
  
  ```
  DateTime::modify(): Failed to parse time string (juni 2017 second sunday) at position 0 (j): The timezone could not be found in the database
  
  ```
  
  **Maybe it doesn't work because the monthyear variable is formed in dutch and not english? (juni = june) If this is the case, how can I modify this to english in order to get it to work?**
  
  Also, my timezone is correctly set to UTC+2 (CEST) - Europe/Brussels via Settings > General
  
  Thanks!
  
  **Tags:** datetime
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-06-05. Score: 3 | Accepted answer
  
  > Maybe it doesn't work because the monthyear variable is formed in dutch and not english?
  
  Yes that's part of the problem. Have a look at PHP's [relative formats](http://php.net/manual/en/datetime.formats.relative.php) page to see what it supports.
  
  You can actually pull off what you're doing with the `this` keyword.
  
  ```
  {% set secondSunday = now|date_modify("second sunday of this month")%}
  {% set lastSunday = now|date_modify("last sunday of this month") %}
  
  ```
  
  You also don't need to define (or override) [`now`](https://craftcms.com/docs/templating/global-variables#now) since Craft will always set that to a DateTime object for you.
  
  > **Comments:**
  > **username_0**: Awesome, thank you very much!  
  
  ---
  
  