Hi Bubble Community,
How do we reference the exact time, without having to refresh the page?
When Today = Thursday, then…
If user leaves the web page open, comes back tomorrow: Today=Friday without having to reload the page?
Basically, How do we reference a dynamic clock, not a static time based on original page load?
Thanks so much!
there is an operator in dynamic expressions :current date/time
What are you using the time for? Display only?
You can use on-page workflows to update page data.
If you’re only displaying the day, then just run a workflow to update the date when it gets to midnight.
If you want to show hours/minute/seconds then use a more frequent workflow action to update the data.
@boston85719, I’ve been using a date picker, but now I dont need to pick the date, so that particular element isnt required anymore (if that might help).
I have two input fields: one for today, one for tomorrow (Today’s date +1)
(both rounded to 12am for easier display of the data, screenshots below)
On Today, when user inputs things for tomorrow, and if they do not close or refresh the browser window, then when the next day comes around: ‘The Today date’ is yesterday’s actual date and ‘The Tomorrow date’ is today’s actual date. If they don’t refresh the page, and make an edit, it screws up the date references in the data.
The data is being displayed based from the same Today date picker
Thank you, @adamhholmes. The idea to run a workflow to update the date at midnight sounds like a simple solution. Any ideas on how might that workflow might look?
Thank you so much.
Using your idea, I’m not sure how to design a workflow to update an element with the current time. I was thinking of using the below constraint to run at 12:01 (so twice a day), but not sure refresh an element or maybe i could refresh the page (if it was left open) to accomplish the same thing?
Yeah, you need to refresh an element.
So the best way is to have your date/time picker inside a group, have that group’s content type set to ‘date’, with the data source set to ‘current date time’, and have the initial content of your date/time picker set to ‘parent group’s date’
Then, my thinking was to use the same conditional workflow you’ve shown above - i.e. when the current date/time: extract hour is 0 and current date/time: extract minute is 0 display data in group (the group your date/time picker is in) with the current date time.
Having just tested it it doesn’t work as the ‘current date/time’ isn’t being updated as it changes, so it’s no good.
However, I found a free plugin that that does allow the current date/time to be referenced in real time as it refreshes every second, so it works when using that.
The plugin is called ‘Current Date Time’ by Mintflow
You just add the plugin element to the page, then reference that instead of the standard Bubble current date/time, and then the conditional ‘only when’ workflow outlined above works.
Alternatively you could just update the group containing the current date time every second yourself in a workflow action and not need to worry about the rest.
I think this might just work with the plugin. You are awesome Adam! Appreciate the collaboration. I’m going to do a little testing and we’ll see what way works, but this plugin is a huge help. I will definitely help the developer & the community know about it.
Your suggestion the other day to use the plugin “current date/time” works fantastic for a dynamic clock. I havent used it yet to refresh the page at midnight yet as a more pressing challenge is taking place:
If you recall, the app writes the date to a field formatted as mm/dd/yyyy, 00:00:00, so Today at 12am, However I have 4 beta testers and 1 has the date writing in as ‘Today at 11pm’, This happens on his laptop and his phone. We tried a new user account and same thing. His data of ‘Today at 11pm’ also displays for him where it should only display if the data in the field is 12am. I’ve been a bit perplexed and working on this for a couple days now.
My hunch: He is the only user at the moment in another timezone. None of the other users have been able to replicate the same error and wondering if more users from other time zones have the same trouble, how might I correct for this? I figured it wouldn’t be timezone related as the time is reference in the user’s timezone anyways (and the time should be converted to 12am from any location).
Is it possible to read in only the date and not the time? That would probably make things much simpler all around.
- This problem is not specific to the plugin, this user was having the same issue even before the plugin’s use
This topic was automatically closed after 70 days. New replies are no longer allowed.