How to convert text into date?

I have read several forum posts about this without finding a solution. I also have tried to use the plugin “Data Converter” from “Copilot”, but it gives me strange results or is not working at all.

How do I convert a string like “2021-12-22” into a date so I can save it to a database field of the type date?

1 Like

Hi @CosmicSelf
Playing with Date is not an easy game.
It’s better to use the good data type on input so that date be recorded in a good way.
But if you have to convert a string (text) into date you should be comfortable with javascript. Read this documentation : Date.parse()
I checked but didn’t find plugin to do so.

1 Like

Thanks for your reply. The input is coming from an external API, so everything is in text format.

You should fetch the data formated in JSON, so the date is normally a timestamp.
Is this data stored in Bubble database ?
Have you tried the API Connector plugin to fetch your data ?

1 Like

There a plugin available for this one. Text to Unix plugin, you need to use 2 action to complete, first things is use the action Text to Unix and then use the Unix to Date

1 Like

You also can use toolbox plugin then an expression, as shown of the screenshot below. You will need to use a bit of javascript but this works very well.
You need to use expression’s result where you want to use converted date.
Note that you can use server script from the same plugin if you need to do the action in the backend.

Capture d’écran 2022-03-14 à 11.18.01

Link to the toolbox plugin


Thanks guys, these are all very helpful information also for future projects.

At the end it was the API settings, that for some reason was set to text instead of date

Thank you @mickceb for this hint!


Could you share what that javascript is? Would like to use the expression element to do this.

use o arbitrary date/time e depois mude o dia, mês e ano com dados do texto.
ex.: 01/01/2023 split ‘/’ = 01 , 01, 2023 . item 1 = 01 item 2 = 01 item 3 = 2023.
não esqueça de converter o texto para numero


Sensacional fórmula! Funciona perfeito! Parabéns! (realmente uma fórmula surpreendente, eu nunca iria pensar nisso! SHOWW)

Thanks, worked a treat when importing CSV date stored as text.

Hi @mickael.vermand,

I see your response when I am looking for a solution to my faced issue. How do I use this expression results, and how do I access it? I want to store it in DB.

I really appreciate any help you can provide.

wow thanks a lot
that worked perfectly

Thank you, this works perfectly!

hi - thanks for this.
However, I get an error telling me to fill out Date/time?
Screenshot 2023-11-09 144613

Hi Christina, you can put whatever you want in there, since it will be overwritten by the rest of the command

1 Like

Hi! This kinda works great but the hours aren’t transforming correctly. Maybe this is a timezone thing? Could you please look at what I’m doing here?

I get a timestamp back from Google’s Calendar API: 2023-12-14T10:00:00-05:00

I’d like to save that as a date/time. So, I’m doing this:

But I get back this:
Screen Shot 2023-12-14 at 6.53.14 AM

So, net-net, the time Google gives me is 10am, but the time conversion spits it out as 3:30pm

Then how can we give dynamic text to it.?