# [Need Help] Manipulting date and time

Hi, I am using the Date/TimePicker and I want the user to be able to input a time that is

rounded down to
nearest 5 minute interval

i.e. if it is 8.44am, it would be rounded up to 8.45

++
When I try to do it on the minimum date, it saves it to the current time rather than up to 5 minutes ahead.
The same occurs when I try to do it on the initial content.

I have tried:

and

and several other combinations.

Can it be done? If so, how? Thanks!!

When I try to do it on the initial content, it gives a time

Iâm not sure I understand what youâre doing with your expression there?.. (the first one just changes the time to 10 past the current hour, and the second one just adds 5 minutes to the current time).

Iâm also not sure why youâre doing any of that in the Initial Content.

So perhaps Iâm completely misunderstanding what youâre trying to doâŚ

But canât you just set the minimum date and time to the current date and time, and set the time interval to 5 minutes?

1 Like

Iâm putting it in the initial content because I donât want the user to have to put in the date - which would be ok if I would work out how to have it have initial content for date but just placeholder for time, but looking at the forums, that appears not to be possible?

Unfortunately, while the time picker shows it as 5 minute intervals, when it saves, it saves as the current time rather than to the nearest 5 minutes. Which would be solved if the user had to input the time, which having a placeholder would solve, were it not for me wanting the date to contain initial contentâŚ

I have a workaround that is less than perfect, but better than before:

At least this way, it rounds to the nearest hour ahead, and it is likely the user will want to change the time. But to the nearest 5 minutes would be better if it were possible

So why are you using a date/time picker here at all (if you donât want the User to have to input the date?)

1 Like

Ah, sorry, I meant that the user will usually want todayâs date, so should only want to click it if they want to input a different date, which they will usually not.

The app is for time blocking, so the user will want to put in different times to start.

I am also encountering an issue with minimum date which, if the user puts a time in in the past, is saving to the past.

Currently it is saving to 10.45 rather than current time (10.47)âŚ

The solution is a bit fiddly (too complicated to explain here)âŚ

So hereâs a working example you can copy from:

Time (bubbleapps.io)

1 Like

Hi Adam, that is fantastic! Also a little complicated to implement - how do I get it to put the parentheses in, and how, in the boolean formatting, do I copy what you put so that it appears blue?

At the moment I have got thisâŚ

I canât get it to add the formatted as text part

Thanks so much for this

Hi Adam, I have tried copying this by writing it out, and by copy and paste, but I canât seem to do it either way. What is the trick? What am I doing wrong?

In the meantime, I havenât been able to reproduce what you wrote exactly - everything except

1. any expression with brackets (I canât reproduce the brackets), and
2. I couldnât get the date time picker to accept the conditional that you added.

I am getting the same thing as before - when the user doesnât change the date time picker before saving, the resultant saved item keeps the current time, whether or not it falls on a 5 minute interval:

FYI, @StandUpâŚ to get the brackets in the expressions, you have to go to the Settings >> Versions tab and enable the experimental expression parentheses feature. With that feature enabled, the parentheses will automatically be inserted into the expressions as you build them.

1 Like

Ah perfect, many thanks, I will have a play

1 Like

Hi Adam, Thanks so much for building that out for me. I have now managed to immitate it, I believe exactly, including conditionals.

However, although the initial content is in 5 minute intervals, if the user doesnât change the time before saving, then the time saved is still whatever the current time is, whether that be on a 5 minute interval or not.

Do you believe I have made a mistake still? Or is what I am asking not actually possible in Bubble?

Thanks again for your help in this, sorry for my novice abilities! A

YesâŚ thatâs not what happens in the demo version i builtâŚ The selected time updates as the actual time changes (in fact the initial time in my version is NEVER the current date/time - itâs always the next fifth minute, and updates in real-time as the time changes) - the selected date/time is shown below the date/time picker so you can see exactly what it is at all times.

So you must have missed something somewhere.

1 Like

Hmm. I have copied it over several times now on several different new pages. I have gone through every element and copied it exactly, but for some reason I still canât see where I am going wrong. The only thing I can see that it might be is on the group number, where, when I inspected it, seems to be showing a 1 where it should be a 5?

The other thing mine is doing which I donât see on yours is that, even though I have the same workflow as yours, whenever I go back to the page, it doesnât update

Also, for some reason it sometimes is giving me other times. for instance, it gave me this

and then self updated to this, despite the time being later

++++

I can see that Group numberâs data source is somehow empty though:

Even though it is not empty

Iâve no idea whatâs wrong, but feel free to share a link to your editor if you want me to take a quick look.

1 Like

I took a look and there are a number of errors in your implementation.

for example, in the Group Numberâs datasource, on the second layer of âFormat as textâ, for the parent âYesâ it should be this (this is mine):

But youâve got this (incorrect):

Then, for âNoâ it should be this:

But youâve got this (these arenât even numbers!):

As far as I can see, those are the only errors though - so fix those and you should be good to go.

1 Like

You seem to be saying you see this on mine:

but I see mine as saying

which is a copy of what I see on yours:

Why are we each seeing different things on each others? Is this something I am doing wrong?

Frustratingly, whenever I try to change âyesâ to â0â, it wonât let me. Every time I do and go out of it, when I come back to it, it reverts to

===

for example, this is my boolean right now:

and then clicking to collapse the boolean, followed by reopening it, it now shows this again:

+++

As such, I have got around it by deleting the expression and putting it in again, and now it seems that something is different, but still not right - what I have ended up with is this for a bit

followed, about a minute later, by this

and now it has changed to this

This is what the inspector shows:

+++

I get this with both Microsoft Edge and with FirefoxâŚ What is going on?

This is what I see of yours when I look at it on my phone browser:

You must be looking in the wrong place.

and then clicking to collapse the boolean, followed by reopening it, it now shows this again:

YeahâŚ again, youâre looking at the wrong thing (there are two layers of boolean statements formatted as text here donât forget).

As such, I have got around it by deleting the expression and putting it in again, and now it seems that something is different, but still not right

Yeah, what youâve currently got doesnât make any sense.

I get this with both Microsoft Edge and with FirefoxâŚ What is going on?

Would I see the same thing if I ran it on a different machine?

No - itâs got nothing to do with that - youâve just implemented it wrong (as I explained in my previous post).

Maybe start again, but be sure to copy exactly what I did (in both layers of âformatted as textâ)

1 Like

Oh wow, mind: blown!! I had no idea that there were or even could be two layers of boolean statements / formatted as texts!! I thought it was just me clicking in the wrong place and weird stuff was happening! Weâre bloody there!!

Thanks so much. Wow!

1 Like