What is the equivalent?

Please excuse my novice status…

…but what is the equivalent of this: ?php echo date(‘Y’);? in Wappler?

Hi JR,
How would you like to use this? Where do you want to show the current year?

I use this in the footer to indicate the copyright info.

The start year and then the php code to update each year afterward, e.g. 2009 - php code

There are no issues to use this code in the page footer. There is no a “Wappler way” - it’s just PHP code :slight_smile:

Okay, no problem… The only reason that I brought it up was because the php code didn’t appear in the Design view of the editor. There might be another method of rending this.

46%20AM

Well, we do not execute the PHP code in design view :slight_smile:

Yes there is another method, using the date and time component, i just don’t see a reason not to use the php code you already have there.

  1. In the App Structure add new component > Data > Date And Time
  2. Bind its value on the page and use the data formatter to format it as you want it to display the data (year only)
1 Like

Thank you for the info! I appreciate it.

1 Like

This is already solved but just a silly piece of added info if you really want to use a custom piece of php code in the app connect side (client side)
Just use your custom php inside a variable

<dmx-value id="var1" value="<?php echo date(‘Y’); ?>"></dmx-value>
{{var1.value}}

The only thing to be aware of when doing this is that you use value="" and not dmx-bind:value=""
Hope this helps with future little things like this.

1 Like

@psweb cool tip, thank you!

If you don’t require the year in dynamic data on the page I would just go with the php code directly <?php echo date('Y'); ?>. Unless you want to use it in some App Connect expression, then use the value component. If you want to have it work without php, then the Date and Time component is the solution.

1 Like