Searching using current date/time

Somehow the current date/time is not ‘updated’ when using it for search inside a conditional. It remains the same value as when the page got loaded. But its refreshed when using it for creating stuff.

Is this a bug or something by design?

This is by design. If you think of it as a custom state that gets set on page load then it’s easier to conceptualize. Referring to current date/time within workflows is always the actual current time, but for things displayed on the screen (such as for your conditional) then it is static upon page load.

I have been using the free plugin “Current date/time” by Mintflow with great success for close to 2 years now. You place it on your page, make sure it’s “visible” on page load even though it’s an invisible element, and refer to it in your conditionals. Super easy workaround.

Awesome.

Btw I am using it for a workflow condition (so do when something happens). But still the current time/date is static.

Plugin works awesome btw!

Thx!
But I need to update it since it’s displaying the user’s machine time.
So, if a user manually changes the time on its device from 5:49 pm to 5:13 pm, the plugin sends 5:13 pm.

only bubble uses the users timestamp right when doing the calculations. They dont use the utc timestamp. SO if you return utc its going to conflict with other stuff…

I was thinking about asking users to send the Bubble’s Current date/time to the plugin as an input parameter. Also, to provide the possibility to set
the custom interval which refreshes the output value. For instance, each 10 seconds, not every one second.

Great idea. If you dont do that, i will haha :slight_smile:

It seems a work-around would simply be to update a custom state at the desired interval and reference the state in the conditional.

If you mean you’re using it in an Only when condition on a WF, then that behavior seems odd. I would expect Bubble’s Current date/time value to be updated whenever the condition is evaluated (which would be whenever the workflow is triggered). In fact, I just did a quick test, and it worked as expected (and as @BrianHenderson described); but perhaps I’m not understanding exactly where it’s being used in your scenario. :thinking:

Hi there,

editor: Date-time-how-it-works | Bubble Editor

page: https://date-time-how-it-works.bubbleapps.io/version-test?debug_mode=true

demo: Vidyard Recording?

Here you can see that the native bubble current date/time is not real time in a only when condition is true workflow. I think this is bad design by bubble.

I fixed it using the plugin but still think this is a bad choice from bubble to have static dates in a when condition is true workflow.

Tried that (sending the current date/time) but bubble sends the date/time off the browser. You need the date/time of the server… Ill try integrating with an time api to get the offset…

Thanks for sharing that demo, @gaimed. Everything in it works as I would expect.

Current date/time is updated whenever the workflow is triggered, which in your demo is only when the page loads and the workflow runs for the first time.

Perhaps a source of confusion is the expectation that Current date/time is being updated continuously. It’s not, so it will never trigger the Do when workflow itself. However, if/when that workflow is triggered, then Current date/time should “return” (evaluate to) the actual current date/time.

It might be helpful to think of Bubble’s Current date/time as a JS call to Date.now(). When invoked, it will return the current date.

As I see it, there was nothing to “fix”; but rather, you found a way to get the desired behavior.

Basically, you just needed to reference a continuously updated date/time value, which can be achieved either with the plugin or by using the technique I described in this post. Both are doing the same thing - i.e. continuously updating a date/time value which can then be referenced from a conditional or Do when workflow.

(Whether that’s the best or most elegant approach, I can’t say, since I don’t understand the full context or the real-world problem you’re trying to solve.)

I’m not sure I understand that statement. Under the hood, Bubble date data types are just big integers representing the number of milliseconds that have elapsed since a particular reference time in the past (known as the Unix Epoch). A given integer (date value) will represent different local times depending on where that date value is being viewed (or more specifically, the time zone setting of the device on which it’s viewed); but it will represent exactly the same instant (moment in time) across all devices / time zones.

Aaah got it! :slight_smile: thnx!