Store today's date in App Connect variable and be able to add/subtract days

I’m working on an appointments feature and want to keep it nice and simple.

I can’t see how to do this in Wappler so would appreciate some tips.

I have created a variable in App Connect called ‘varDate’ and want to set the default value to today.

I have two buttons - ‘Previous’ and ‘Next’. I want these to subtract or add a day to the date in the variable.

In doing this, I can query the data and show the appointments for the selected day.

I thought this would be straight forward and was expecting to see the {{NOW}} option in App Connect but it’s not there. And entering it manually didn’t produce anything.

How should I do this?

The Date and Time element can provide you with the current date/time. Add that to your page with the settings that make sense for you.

1 Like

Doh! Of course. Completely forgot about that. Thanks Ken.

1 Like

A quick follow-up question if I may.

I now have today’s date stored in my variable. How do I add a day or subtract one? I’m thinking it’s the dateAdd command but not sure of the syntax.

This is what I’ve tried:
dmx-on:click="varSelectedDate.setValue(varSelectedDate.value.dateAdd('days', +1))"

That looks correct. I think a bug might have slipped in. The dateAdd formatter does not show up under the date items, and the dateAdd formatter does not work for me.


1 Like

I appreciate your help, @mebeingken.

1 Like

@George - do you know if this is a bug? Should I persist with trying to get it to work? It’s beginning to get a bit urgent so would be good to know how I should tackle it.

We will check what’s wrong there.

1 Like

We found the problem - it’s just a minor UI issue, and it will be improved in the next update.
Meanwhile you can just add: .addDays(1) to your date, in order to add a day to it.
Don’t forget the formatter js file must be included in the head tags.

1 Like

Superb. I’m onto it :slight_smile:

PERFECT! Works like a dream. Many thanks for that.

1 Like

Output the current date like this:


Thanks Street!

So this is the equivalent to php’s echo date(); ? Cool.

Thanks again, but, this is what finally worked: {{“NOW”.toDate().formatDate(“MMMM dd, yyyy”)}}

It needed the .toDate() …