Answers.Body: <p>The version below could be more understandable in some cases.</p>
  
  <p>First day of week <em>(assuming Monday is the first day)</em>:</p>
  
  <pre><code>{{ now | date_modify('monday this week') | date('m-d-Y') }}
  </code></pre>
  
  <p>or alternatively:</p>
  
  <pre><code>{{ now | date_modify('this week') | date('m-d-Y') }}
  </code></pre>
  
  <p>Last day of week <em>(assuming Sunday is the last day)</em>:</p>
  
  <pre><code>{{ now | date_modify('sunday this week') | date('m-d-Y') }}
  </code></pre>
  
  <p>First day of month:</p>
  
  <pre><code>{{ now | date_modify('first day of this month') | date('m-d-Y') }}
  </code></pre>
  
  <p>Last day of month:</p>
  
  <pre><code>{{ now | date_modify('last day of this month') | date('m-d-Y') }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-15T15:44:28.793Z
Answers.LastActivityDate: 2019-05-17T07:44:10.803Z
Answers.LastEditDate: 2019-05-17T07:44:10.803Z
Answers.UserDisplayName: Romain P.
Answers.Body: <p>That code in Twig would be:</p>
  
  <pre><code>{% set day = now|date('w') %}
  {% set weekStart = now|date_modify("-#{day} days")|date('m-d-Y') %}
  {% set weekEnd = now|date_modify("+#{6-day} days")|date('m-d-Y') %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-13T11:21:28.400Z
Answers.Text: I noticed that there's a difference between `now` and `'now'`, Brandon. `now` not returning the date calculated to be in the right timezone?
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-24T16:12:02.310Z
Answers.Text: @carlcs We fixed that in [Craft 2.4.2670](http://buildwithcraft.com/updates#build2670) :)
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-30T09:31:37.877Z
Answers.LastActivityDate: 2015-04-30T09:31:37.877Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>If i provide the week#, how might i go about getting the first day (and month) and the last day (and month) of that particular week?</p>
  
  <p>This week for instance would be April 26 and May 2</p>
  
  <p>I know in PHP i can do the first and last day of the week like so:</p>
  
  <pre><code>$day = date('w');
  $week_start = date('m-d-Y', strtotime('-'.$day.' days'));
  $week_end = date('m-d-Y', strtotime('+'.(6-$day).' days'));
  </code></pre>
  
  <p>But i'm not sure how to translate that to twig and of course also include the month.</p>
  
Tags: <templating><datetime>
Title: First and Last day of Week + Month in Twig
ThreadText: # First and Last day of Week + Month in Twig
  
  (Asked by: username_0 on 2015-04-30)
  
  If i provide the week#, how might i go about getting the first day (and month) and the last day (and month) of that particular week?
  
  This week for instance would be April 26 and May 2
  
  I know in PHP i can do the first and last day of the week like so:
  
  ```
  $day = date('w');
  $week_start = date('m-d-Y', strtotime('-'.$day.' days'));
  $week_end = date('m-d-Y', strtotime('+'.(6-$day).' days'));
  
  ```
  
  But i'm not sure how to translate that to twig and of course also include the month.
  
  **Tags:** templating, datetime
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2015-04-30. Score: 9 | Accepted answer
  
  That code in Twig would be:
  
  ```
  {% set day = now|date('w') %}
  {% set weekStart = now|date_modify("-#{day} days")|date('m-d-Y') %}
  {% set weekEnd = now|date_modify("+#{6-day} days")|date('m-d-Y') %}
  
  ```
  
  > **Comments:**
  > **username_3**: I noticed that there's a difference between `now` and `'now'`, username_2. `now` not returning the date calculated to be in the right timezone?  
  > **username_2**: @username_3 We fixed that in [Craft 2.4.2670](http://buildwithcraft.com/updates#build2670) :)  
  
  ---
  
  ### Answer by username_1 on 2019-05-15. Score: 5
  
  The version below could be more understandable in some cases.
  
  First day of week *(assuming Monday is the first day)*:
  
  ```
  {{ now | date_modify('monday this week') | date('m-d-Y') }}
  
  ```
  
  or alternatively:
  
  ```
  {{ now | date_modify('this week') | date('m-d-Y') }}
  
  ```
  
  Last day of week *(assuming Sunday is the last day)*:
  
  ```
  {{ now | date_modify('sunday this week') | date('m-d-Y') }}
  
  ```
  
  First day of month:
  
  ```
  {{ now | date_modify('first day of this month') | date('m-d-Y') }}
  
  ```
  
  Last day of month:
  
  ```
  {{ now | date_modify('last day of this month') | date('m-d-Y') }}
  
  ```
  
  
  ---
  
  