# Bubble changes dates when storing them

**URL:** <https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420>\
**Category:** Database\
**Created:** [July 11, 2021, 12:30am UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420 "2021-07-11T00:30:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxiogas](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/maxiogas/32/81699_2.png) [@maxiogas](https://forum.bubble.io/u/maxiogas)\
**Post date:** [July 11, 2021, 12:30am UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420/1 "2021-07-11T00:30:44Z")

</div>

Hello everyone, sorry for the hour 😅, I’m going to leave this question here in case someone can help me.

Something very strange is happening to me.

In my workflow, I was having a problem. When creating a new record in my database, I was trying to save a date.

What happens is that in the workflow I can see that everything is running fine and the date matches what I want to save.

But, then in the database, the record does not match.

You can see in the images that the workflow indicates the following dates:  
Deal of the day: Jul 1, 2021 1:00 am  
Text: Jul 1, 2021 1:00.

![Captura de Pantalla 2021-07-11 a la(s) 2.13.33](https://us1.discourse-cdn.com/bubble/original/3X/b/a/baf1c44f7db964f28126df78eaf2ce973433a81f.png)

Basically I am storing the same value only in two different properties, the first is stored in date format and the second in text format.

In the other image you can see how the record does not match the workflow.

 ![Captura de Pantalla 2021-07-11 a la(s) 2.14.03](https://us1.discourse-cdn.com/bubble/original/3X/d/6/d6c020a0bf6221676ce41749cbda9ac6d731666d.png)

“Deal of the day” matches, but in the “text” property the record does not match what the workflow indicates, it saves a different date and time.

I can’t find out why this happens.

Technically, if I am using the same source for the date and in one it is stored correctly, in the other it should be stored the same.

In the workflow you can see that the date is not altered, a new record is simply created without any change.

Even if I try to save the current system date the same error occurs.  
In one property it is stored correctly and in the other it changes the time.

![Captura de Pantalla 2021-07-11 a la(s) 2.24.24](https://us1.discourse-cdn.com/bubble/original/3X/c/a/cab4372807c235475b1d46d6ce87d0031b8845ec.png)

 ![Captura de Pantalla 2021-07-11 a la(s) 2.24.13](https://us1.discourse-cdn.com/bubble/original/3X/d/0/d0621acbc3972fe1c74b5b1418441584b7c9a65b.png)

Anyone have any ideas or something similar happened?

---

<div class="post-metadata">

**Author:** ![BrianHenderson](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/brianhenderson/32/231409_2.png) [@BrianHenderson](https://forum.bubble.io/u/BrianHenderson)\
**Post date:** [July 11, 2021, 12:51am UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420/2 "2021-07-11T00:51:40Z")

</div>

Are you familiar with the concept of UTC or “Zulu” time? I wonder if you’re encountering something related to time zones.

---

<div class="post-metadata">

**Author:** ![rpetribu](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/rpetribu/32/90852_2.png) [@rpetribu](https://forum.bubble.io/u/rpetribu)\
**Post date:** [July 11, 2021, 1:08am UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420/3 "2021-07-11T01:08:44Z")

</div>

Hi 👋

What is the action you are using to save this in your database? Could you share it?

---

<div class="post-metadata">

**Author:** ![maxiogas](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/maxiogas/32/81699_2.png) [@maxiogas](https://forum.bubble.io/u/maxiogas)\
**Post date:** [July 11, 2021, 2:05am UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420/4 "2021-07-11T02:05:02Z")

</div>

Is just crearte a thing. Just a simple action

---

<div class="post-metadata">

**Author:** ![maxiogas](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/maxiogas/32/81699_2.png) [@maxiogas](https://forum.bubble.io/u/maxiogas)\
**Post date:** [July 11, 2021, 2:06am UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420/5 "2021-07-11T02:06:37Z")

</div>

I thought the same thing. but if I am saving exactly the same date in the two properties the same dates should be saved, there is my doubt.

---

<div class="post-metadata">

**Author:** ![BrianHenderson](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/brianhenderson/32/231409_2.png) [@BrianHenderson](https://forum.bubble.io/u/BrianHenderson)\
**Post date:** [July 11, 2021, 3:26am UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420/6 "2021-07-11T03:26:04Z")

</div>

Well, it seems you’re dealing with two data types: A date, and a text. In Bubble, by default a date/time value will always show in your time zone. However, a text value is static. I still suspect you’re running into something like this but you haven’t provided screenshots of exactly what you’re doing so it’s all speculation.

---

<div class="post-metadata">

**Author:** ![rpetribu](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/rpetribu/32/90852_2.png) [@rpetribu](https://forum.bubble.io/u/rpetribu)\
**Post date:** [July 11, 2021, 5:53am UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420/7 "2021-07-11T05:53:12Z")

</div>

Yeah…  
The problem should be in the “create a thing” action…

---

<div class="post-metadata">

**Author:** ![boston85719](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/boston85719/32/77286_2.png) [@boston85719](https://forum.bubble.io/u/boston85719)\
**Post date:** [July 11, 2021, 9:26am UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420/8 "2021-07-11T09:26:44Z")

</div>

This is associated with what @BrianHenderson mentioned. The date value you see in the database is shown in your current timezone. Chances are you are running the function to create the entries and the date value has a different timezone applied than your current timezone. Also, if you are seeing this when a user in another timezone creates the entry, that is why too.

You need to save the dates in such a way that they are stored using the timezone they are meant to be for.

---

<div class="post-metadata">

**Author:** ![sudsy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sudsy/32/114637_2.png) [@sudsy](https://forum.bubble.io/u/sudsy)\
**Post date:** [July 11, 2021, 6:01pm UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420/9 "2021-07-11T18:01:25Z")

</div>

> [@maxiogas](#):
>
> You can see in the images that the workflow indicates the following dates:  
> Deal of the day: Jul 1, 2021 1:00 am  
> Text: Jul 1, 2021 1:00.  
> […]  
> if I am using the same source for the date and in one it is stored correctly, in the other it should be stored the same.
> 
> ![forum-solution](https://us1.discourse-cdn.com/bubble/original/3X/d/0/d0621acbc3972fe1c74b5b1418441584b7c9a65b.png)

In fact, they both represent **exactly the same instant (moment) in time**. It’s just that the text version is in UTC, and the date version is displayed in your browser’s time zone; so both @BrianHenderson and @boston85719 were on the right track.

Why was the text version saved in UTC? Simple. You didn’t tell it otherwise. UTC is the default if a time zone is not explicitly set.

Therefore, you can get the behavior you want by specifying the date format and choosing the desired time zone…

 ![datetime-as-text](https://us1.discourse-cdn.com/bubble/original/3X/d/f/dffc7675577b5ade6af76d7eb58980e7aabbf12f.png)

And if you use the “Z” format specifier, it’ll output the timezone so you can see for yourself.

### HOWEVER

Having said all that, the burning question is, why is a date being saved as text to begin with? Generally speaking, it’s bad practice. There are [rare] instances where it might make sense, but it’s usually a bad idea. Date/time values should be preserved as such, as they take up less space, are more performant, and more flexible. All date/time info is preserved if it’s stored as a **date** data type. That’s lost when it’s converted to a string of characters.

-Steve

---

<div class="post-metadata">

**Author:** ![boston85719](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/boston85719/32/77286_2.png) [@boston85719](https://forum.bubble.io/u/boston85719)\
**Post date:** [July 11, 2021, 6:21pm UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420/10 "2021-07-11T18:21:41Z")

</div>

> [@sudsy](#):
>
> Why was the text version saved in UTC? Simple. You didn’t tell it otherwise. UTC is the default if a time zone is not explicitly set.

I’m a bit confused. Wouldn’t the default timezone be the users current timezone unless otherwise explicitly set?

When saving the text field as the dynamic expression for current date/time, the timezone selection is the user’s current timezone, so the text value should be that, and only UTC if the user was in UTC timezone.

---

<div class="post-metadata">

**Author:** ![sudsy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sudsy/32/114637_2.png) [@sudsy](https://forum.bubble.io/u/sudsy)\
**Post date:** [July 11, 2021, 6:42pm UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420/11 "2021-07-11T18:42:20Z")

</div>

> [@boston85719](#):
>
> Wouldn’t the default timezone be the users current timezone unless otherwise explicitly set?

Nope. It’s quite simple to test. See for yourself.

> [@boston85719](#):
>
> When saving the text field as the dynamic expression for current date/time, the timezone selection is the user’s current timezone

But **there is no “timezone selection”** until / unless it’s explicitly set. Remember, this is happening **server-side** when creating a thing - not in the browser - and [the Bubble Manual](https://manual.bubble.io/core-resources/data/operations-and-comparisons#date-type) states, “In situations where a web browser is not involved […] we use UTC time in our calculations.”

-Steve

---

<div class="post-metadata">

**Author:** ![boston85719](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/boston85719/32/77286_2.png) [@boston85719](https://forum.bubble.io/u/boston85719)\
**Post date:** [July 11, 2021, 6:53pm UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420/12 "2021-07-11T18:53:36Z")

</div>

Never knew that. Would have assumed the text would be saved as the users default timezone.

I’ve done some tests and now understand the differences.

If you use formatting options, the default timezone is the users current timezone and it is applied to the value saved in the database

 ![Screen Shot 2021-07-12 at 1.49.23 AM](https://us1.discourse-cdn.com/bubble/original/3X/3/1/31dab4a90feb2ac00bbe9977a3b1981fe4211df6.png)

 ![usertimezone](https://us1.discourse-cdn.com/bubble/original/3X/f/d/fd930c88e8388229e0525b36179b45523628e5b1.png)

However, if you don’t use the format operator the default timezone is UTC and the text value will be saved in UTC, while the date will be in the Users Timezone.

 ![Screen Shot 2021-07-12 at 1.51.31 AM](https://us1.discourse-cdn.com/bubble/original/3X/0/3/038cbf8adbec43066b825fa0032d81e8770fa567.png)

 ![Screen Shot 2021-07-12 at 1.52.00 AM](https://us1.discourse-cdn.com/bubble/original/3X/b/f/bfc54538ef1f1930f2bd56f3ea2a87cb4992be13.png)

---

<div class="post-metadata">

**Author:** ![sudsy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sudsy/32/114637_2.png) [@sudsy](https://forum.bubble.io/u/sudsy)\
**Post date:** [July 11, 2021, 7:08pm UTC](https://forum.bubble.io/t/bubble-changes-dates-when-storing-them/159420/13 "2021-07-11T19:08:51Z")

</div>

> [@boston85719](#):
>
> while the date will be in the Users Timezone.

A **date** data type isn’t actually **IN** _any_ time zone. Time zones are relevant only for display and manipulation for/by humans - not for storage (unless the date is stored as text, in which case having an associated time zone allows the precise moment in time to be reconstructed into a proper **date** type).

Behind the scenes, **dates** in Bubble (as with most modern computer systems) are nothing more than integers - really big integers, but integers nonetheless.

Basically, time zones are an artificial construct invented by humans so that a given _time_ in a particular time zone represents roughly the same _time of day_ around the world.

-Steve
