Jump to content

Recommended Posts

Hi all!

 

I am creating a little own calendar.

Now I want to add a "previous week" and "next week" functionality to the calendar.

 

It is easy to take $thisWeek - 1; and $thisWeek + 1;, but there has to be a check wether it is the last week of the year and it should actually be a new year and head to week number 1.

 

HOW do I make this kind of function?

 

I use the following string names:

$thisYear

$thisWeek

 

Thanks a lot for you help!

 

Sincerely,

Andreas

There isn't an easy solution to what you're after for this reason: weeks go from Sunday through Saturday, and the dates of the year very seldom overlap exactly with the week. So, if January 1 falls on Wednesday, you could accurately report it as either week 52 (for Sunday through Tuesday) or week 1 of the following year (for Wednesday through Saturday).

 

Either way, simply grabbing weeks of the year is a little more difficult than simply checking what week of the year the current week is. Can you maybe define a few more rules for what you're after? If you can, I'm sure we can help you come up with a solution.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.