Forum Documentation Showcase Pricing Learn more

Dates and Days Error


So a user selects a date with the date picker, (say 1 January) and in Bubble it gets stored as midnight (12am) on that day.

I write a plugin, and have exactly the same code which runs locally as an element plugin and in the server as a server plugin.

The element code correctly interprets the date value as being 1 January.

The server code interprets it to be 31st December.

Why is that?


Time zone difference between client and server perhaps?

1 Like

Bubble server are PST time zone. It’s hard when you are using api workflows to track the user from another time zone. I build a table of time zones to track the difference.


But I’m not using “current time”… I’m just displaying the date value in some text!


Remember that dates specify a unique moment in time. This moment in time is the same for all users everywhere.

Bubble server time is UTC timezone ID. As I write this, it is:

7:32 AM
Friday, May 10, 2019
Timezone ID: Coordinated Universal Time (UTC)

But where I’m located, it’s:

12:32 AM
Friday, May 10, 2019
Timezone ID: America/Los Angeles (PDT)

As you can see, if I wrote this 33 minutes ago, UTC time would have been:

6:59 AM
Friday, May 10, 2019
Timezone ID: Coordinated Universal Time (UTC)

And, in SF:

11:59 PM
Thursday, May 9, 2019
Timezone ID: America/Los Angeles (PDT)

So that’s how that happens.

Add’l info: Without some extra help, JavaScript (and, by extension, nodejs) can only construct dates in the browser timezone (which is server timezone in nodejs). The workaround is to understand this when you are constructing dates. If you need to construct a date in a specific zone, use something like moment-timezone to help get it right.


This post was flagged by the community and is temporarily hidden.


It must be to do with how the time midnight is interpreted on different systems… I must say I’m never sure whether it is the last minute of the last day, or the first minute of the next!


If you want to follow standard practice, use the first minute (first millisecond to be precise) of the next day (a.k.a exclusive dates).
This is the ical standard for calendar events. I use this in my Air Calendar plugin.