Date and Time returning [object Object]?

I was having an issue where using the hoursUntil formatter the time was returning as NaN, which was odd, so I decided to do a bit more debugging and just add in the variable of the “Date and Time” component on the page to make sure that was printing correctly, to which I can see it is only returning [object Object], which I’m guessing is why the hoursUntil formatter was returning NaN.

Is there any particular reason as to why this might return [object Object]? The server model is PHP, and the PHP timezone is set correctly.

Wappler Beta 10. Using a simple php echo to show the time/date displays it correctly.

With the Date and Time component you probably mean the App Connect component, which is a client-side JavaScript component and has nothing to do with PHP. How does the expression look like that you are using?

If you mean the datetime component in the App structure, it will return an object as it has multiple properties. To get the actual date from it add .datetime to the reference:

e.g.
image

to get the datetime I would refer to this with:

var_datetime.datetime

You can then format the date using the formatDate() formatter.

If you are adding values to your page using code, I would suggest using the date picker and magic wand to apply formatters as it guides you through with the required parameters for each formatter.

Ended up getting it working, thanks!

It was due to me not adding the .datetime after the var. It’s weird that the picker doesn’t do this for you when selecting it, though. This is what I had to format the date, and it was originally returning NaN until I added “.datetime” after the var in “Date:”

What it sets by default (Which returns NaN) after selecting the time and date variable:
Capture1

Manually adding datetime after the variable (Which then makes it work).
Capture