Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First and last day of the week #47

Open
iBet7o opened this issue Jun 18, 2017 · 0 comments
Open

First and last day of the week #47

iBet7o opened this issue Jun 18, 2017 · 0 comments

Comments

@iBet7o
Copy link

iBet7o commented Jun 18, 2017

Hi!

I need to show the first and last day of the week with the format {{ first_monday_number }}-{{ last_saturday_number }} {{ month_name }}. Example with the week number 24: 2017-06-12 to 2017-06-18

<?php

$year = $request->query->has('year') ? $request->query->get('year') : date('Y');
$weeknum = $request->query->has('weeknum') ? $request->query->get('weeknum') : date('W');

$week = $this->get('calendr')->getWeek($year, $weeknum);
$weekEvents = $this->get('calendr')->getEvents($week);

In the twig template:

{{ week.begin.format('j') }} - {{ week.end.format('j') }} of {{ week.format('F') }}

The problem is in {{ week.end.format('j') }} , print "12 - 19 of June" and I need the last day to be on Saturday: 12 - 17 of June.

How can I get the correct date?

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant