Convert text to date - quick tip

Bubble doesn’t have a native “convert to date” expression so when you’re using a ternary expression (i.e. format as text) and you want to input a default date, it’s not as easy as you might think.

e.g. If you want to create a new Thing with a default of today’s date (e.g. when no date is selected for your Thing) you can try the equivalent of:

DateSelector.value.is_empty ? CurrentDateTime : DateSelector.value

And it will complain that it’s expecting a date but you’ve given text.

Solution?

Toolkit to the rescue…

  1. Drop an “expression” element on your page
  2. Put the expression within new Date (‘’)

  1. Use that Expression.value in your workflow instead of your input’s
  2. Bask in the feeling of you solving something using Javascript in your no-code app :flexed_biceps:

Hope it helps.