How To Show The Current Week Of The Year – Bubble.io

Are you building a to-do list app, project management tool, or a digital calendar? Within each of these use cases, displaying the current week of the year is an essential feature.

The process to show the current week of the year in Bubble.io includes:

  1. Formatting your Bubble elements
  2. Creating a formula to show the current week from a date
  3. Updating the week in real-time

Full Transcript of Tutorial

1. Formatting your Bubble elements

Within a Bubble editor, I’ve created a demo to-do list app. As you can see, at the top of the page, this app displays the current week of the year written as a number. At this point in time, it’s currently week 12.

So how do we actually calculate this within a Bubble application? If we open a Bubble editor, we can walk through this entire process from scratch.

We’ll start by adding a text element onto our page. If you’d like, you can choose to format this as a heading. We’ll also take the time to update the responsive settings of this element. 

If you select the text element, then open the layout tab, you can set the minimum width to 0px. We’ll also update the maximum width setting to an infinite size. This will allow the text to become fully-responsive, regardless of the users browser.

While here, we’ll also then update the minimum height of the text element to 0px to ensure that the element wraps nicely around the text within it.

2. Creating a formula to show the current week from a date

After formatting our text element, we can now build the dynamic expression that can calculate the current week of the year. Before displaying the week as a number, it’s important to first add the word ‘week’ written as text. This will allow us to format the end text as ‘week 12’ instead of just displaying the number 12.

Finally, we can insert dynamic data and reference the ‘current date/time’. If we then select the ‘more’ option, you’ll see the ability to extract a value from this date. In this instance, the value we’ll want to extract is the week.

If you’d like, it’s also possible to extract any additional values from the date. This can include the year, the month, the day, the hour, etc.

3. Updating the week in real-time

Now, if we were to run a preview of our application, we’ll see that the value of the date has successfully formatted as a week. Thankfully, this value will automatically update in real-time. For example, next week, this number will display ‘week 13’. 

And just like that, you now know how to calculate and show the current week of the year directly inside your Bubble app.

Never miss a course 👇