Time Entry - mm:ss

I am creating an app that allows users to enter times for certain distance runs - 200m, 400m, 800m & 1600m. They need to submit their times in mm:ss format. I have tried using the AirTimeDropper plugin but I can’t seem to get the format right. Any suggestions?

I think the default picker uses MM:ss

Hi @ccaste,
The AirTimeDropper by default returns a time as hh:mm (which is a text, no second) if you call AirTimeDropper's value , and you can also get the hours or minutes individually as numbers and format them whichever way you want as text.

The default Date/Time picker returns a date value which can be formatted as time in hh:mm:ss or hh:mm, etc.
But when you call the formatted as: on a date value what is returned is just a text, like what the AirTimeDropper give you.
Basically there is nothing like time only, time is a component of date. So you can take a date value and get only the time component as text formatted in different ways. That’s how the default date/time picker works.
AirTimeDropper just gives you a time only text (not a date value) as well as a hour (as a number) and minute (as a number) and you’re free to format it whatever way you want.

I’m brand new to Bubble and so I might need a little more detail when explaining this. But basically, I have a form that requests a time for a person’s 500m run. That time might be 1 minute and 45 seconds. How can I record this in the database so that I can use this information in the future to compare this user’s time to another or to make other calculations?

First what you store will depend on the calculations you perform.
Secondly it seems from the little info you’ve provided that what you’re interested in is not time a moment but time as a duration. If this assumption is correct then you don’t need a time picker for this.
You can just use a normal text field for the user to enter their minutes and seconds, or some dropdown or spinner elements.
Also note that the AirTimeDropper (as well as the default date/time picker) allow you to select only hours and minutes and not minutes and seconds.

So the simple answer is that if you’re interested in duration (with minutes and seconds) dont use a time picker.

Got it. But will a calculation be possible if the field is a text field?

No, you will have to store them as numbers. So for example if you’re interested in minutes and seconds, you can have two fields on the user, one to store the minutes and one to store the seconds. Then if you want to know if one duration is bigger that the other, you can first compare the minutes and if they’re equal compare the seconds.

When you compare date/time like you were previously doing, what you’re actually comparing is whether one date (or moment) came before another or they’re the same moment. It’s not a comparison of duration. Duration is a difference between two date/times (moments)

So set up a minutes field and a seconds field as numbers and then calculate from there?

Yes. Actually you don’t even have to store the minutes and seconds separately. You can store everything in seconds by converting the minutes to seconds and adding it to thr seconds.
For example 2min 30sec will be 150 seconds (i.e (2 × 60) + 30).
This way it will be easy to compare the durations and do other calculations.
On the front end wjen displaying the duration you can also concert back the total seconds to minutes and seconds.
For converting the total seconds to minutes and seconds you can do this:
minutes = totalSeconds / 60
seconds = totalSeconds % 60. The % means modulo, that is remainder.

1 Like

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