When is a Date not a Date

There seem to be some fundamentals about dates and date/times in Bubble that I don’t understand.

What is a Date field type? Is it always a date/time value? If so, how can I reliably control its value when I only want it to contain date value, not date/time values? How can I reliably control its value when I only want it to contain a time value?

The Bubble manual and reference are not helpful.

If I search in the reference for date, the result has little to do with date types or functions:

If I search the manual for date, the result has absolutely nothing to do with dates:

In the forum, I see lots of questions about dates and times with very specific solutions to specific problems. What I don’t see anywhere is something that makes the underlying concepts and related tools clear.

My specific case is that I need to assign the current date to a field when I create a thing. I’ve tried using :formatted as 3/1/18 but that becomes a text value that cannot be assigned to the field.

image

image

Where can I go to really make sense of this?

1 Like

First of all re-check your database that “WhenDue” field is “Date” type and not “Date range” or “Date interval” or another type.

You should be able to save a Current Date/Time in a “Date” field.

Actually there’s a difference between Date and :formated as text.
When the value still as Date (you can do other related operations like +add day, extract values from that date… and more)

But not when its a text. So usually you will need use :formated as text only on specific cases (Example: custom format for that date (instead of 03/02/2018 -> 03/02/18 or 02/03/2018 (MM/DD/YYYY - DD/MM/YYYY or time formatting like HH:MM:SS:MS).

Important: You cant save on a DATE type an :formated text date, because that’s TEXT and its incompatible with Date type.

If you have more questions feel free to ask.

Perhaps it will help if I am a bit more direct.

WhenDue is of type Date.

When I assign Current date/time to it, what will WhenDue contain? today’s date? today’s date and time? If it’s today’s date and time, what is the proper way to assign just today’s date without time?

Asking even more directly, what is the proper way to assign today’s date, without time, to WhenDue?

Hey sorry for the delay. Im from the mobile so i its bit tricky to add images.

So when you save date/time into db it saves both (date and time). When you want to pull that data for show It to the user then its when you have to use :format as text

In the case you want to show only date in :format as text you can select then what you want to show, only date, date+time, only time.

So basically “date” is used for dynamic date, and format is static text.

When you format the date you cant save It anymore as date but as text.

Hope that resolves your questions.

Just to add on to @yusaney1’s response, which is accurate, I think knowing a bit more about the format of the date/time type will help.

Bubble saves date values as UNIX, which is inherently a value that indicates a date and time.

This makes a date value in the database zoneless. By default, Bubble will display date values according to your local timezone. If you look at dates in your App data then change your computer’s zone, you’ll see the change.

So, it’s up to you to display the date value:

  1. For local zone (default) or a specific zone (with :formatted as)
  2. As an extracted date or time only if that’s what you want (with :formatted as)

Yes, as soon as you format a date, you strip it of its date and time properties, so do whatever date math if needed before you format to a custom text display.

If your use case for the date value is the date part only, it’s ok that the time is also technically in there. Just extract the date only any time you want to display it and ignore the time… as @yusaney1 said.

Hope this clears things up.


Gaby | Coaching Bubble
Private coaching, courses, and tons of free resources

1 Like

Thank you, Gaby.

It seems to me that the subject of dates and times in Bubble warrants a substantial explanation, i.e. many blog posts or a manual unto itself.

Perhaps I need some time to get my head turned around to really understanding how to use the Bubble functions related to Date types. I am so accustomed to thinking of date, time and date/time as independent data types. Having date and time reliably stored separately when I need time, I can easily trigger actions based on calendar date or time of day.

I also need to get clear on the concepts of universal time (UNIX timestamp) and representation of time shifting based on time zone.

Since the app I’m developing is a task management system with some calendar intelligence, and tasks can be due at a specific date/time or any time on a given date, I need to get clear on how all this works. This is especially true when considering that uses can travel among time zones. Since I haven’t even gotten close to “MVP” status, I haven’t thought about a reasonable set of use cases that should be supported.

When I’m done with all this, I could probably write the Bubble date/time manual, but in the meantime, I guess I need to address one scenario at a time and lean on the forum for help.

One other side question:

In the article you linked to about UNIX timestamp, there was reference to a 32-bit limitation. (“What happens on January 19, 2038?”) Does that apply to Bubble Dates or is Bubble using a 64-bit timestamp?

(I’m really surprised this isn’t explained or can’t be found via search in the Bubble Manual or Reference.)

Thanks!

Thanks, @yusaney1, for helping me start looking in the right places.

You’re not alone. I used to to think of them seperately until i started creating date and time plugins.
I hard to unlearn some things and view date/time in a new way. I’ve had to answer several questions in this regard because i have 3 bubble plugins that deal with date/time.

But the simple way to understand this is to ask yourself, what is time?
When we say 2:30pm, what do we really mean?
If i ask you to meet me at 2:30pm what am i saying?
It will struck you when you think about this more that whenever we mention time, there is an implicit date.
For example if i say, Hey laurence, i have some info for you let’s meet at 2:30pm.
You’re likely going to ask, 2:30pm on what date? If you don’t ask it means there is common understanding of the day we’re meeting at 2:30pm.

So as you can see, there is no concept of time only. Whenever you mention time, there is an implicit date.
This is why in most computer systems, not bubble alone, there is the date/time object.
Whether you’re interested in only the time component or the date component (day, month, year), you have to store and perform operations on the whole date/time object.
And depending on your needs you can extract the component you need.
Hope this helps others who may also be thinking of date, time and date/time as separate concepts.

3 Likes

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