Need help with time hour calculator

How Should I Save Dates for a Simple Timecard Calculator?

Hi everyone,

I’ve built a timecard feature that works perfectly on the front end, allowing employees to input how much they’ve worked on a job. Now, I need to save this data to the back end and want to make sure I’m doing it the right way. It’s connected to the employees job. Usually I would start with backend for data however I rarely work with dates.

Here’s what I’m working with:

  • Employees fill out their time worked, including:
    • Start time
    • End time
    • Date
  • I’d like to calculate the total hours worked and store everything in the database. Probably use the sum

I hate working with dates its like my least favorite bubble thing here’s some images

How the front end works

I’ve got most of it working, but I’m still facing an issue with date duplication. I’m using three dates: a Start Date, an End Date, and a reference Date. This allows me to calculate the sum of hours by subtracting the total End Time from the Start Time. The reference date is used in my repeating group so I can make changes and automatically save the data.

The biggest issue now is that dates are being duplicated. I’ve cleared all the conditionals, but because the table I’m using isn’t specifically for Start or End dates, but rather the reference, When I try to remove first date it literally just remove the first item on the list. I want it to remove the specific date.

Essentially I just can’t get the wf logic to work to delete the duplicated < date and replace it with a new date.

Duplicate example at the bottom.

Hear that. In this case, and in many cases in Bubble regarding manipulating times, I’d make start and end time number fields, which should make it much smoother to interact with on your app…

Don’t use the front-end for this. Start a timer with API. Track the time it started, and the time it ended. Have the API respond back with the total time elapsed.

For the front-end part, you just use any timer plugin that can take those parameters and adjust accordingly.

I have built an off-site API system to handle this, I can add you to the waiting list if you like.

This way, your times are all accurate and will always be server-side.

Okay, how would I go about having the proper date attached to the number fields? It seems so simple just like check to see if date is Curren rows date if is it delete and then replace if not but for whatever reason I can’t seem to get not bug out.

For this are you talking about a manual entry time calculator like mine. Or something with a clock in clock out?

I didn’t read the full post like I should-have.

The best library I have used for these types of calculations is Moment. There is a plugin available that can do that for you.

Ideally, you add in two parameters (the start and finish time), and it’ll output the time in between for you.

I have that figured out. My issue is updating the dates. My conditionals for updating them don’t work on a list it just replaces whatever the first date is or if I change the conditionals duplicates the dates. Especially when I have a list of dates.



Something like this?

I will have to dig into the app to get its logic, but I have it where you can add timelogs and reports and it’ll calculate their time spent overall where they can edit/create/delete logs as well.

Yes, modeling after this I have listed jobs that helpers can update there hours on. I’m using air/date time picker instead of changing hours, minutes, with input.

This topic was automatically closed after 70 days. New replies are no longer allowed.