Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helper not working #425

Open
lcsqlpete opened this issue Jan 10, 2025 · 0 comments
Open

Helper not working #425

lcsqlpete opened this issue Jan 10, 2025 · 0 comments

Comments

@lcsqlpete
Copy link

lcsqlpete commented Jan 10, 2025

I'm using the PHP version of Mustache and have defined a helper to convert a date in yyyy-mm-dd format to mm/dd/yyyy format which looks like this:

`'_mdy' => function ($ymd) {
            return date("m/d/Y", strtotime($ymd));
        }`

I am using it in a template like this
{{#concerts}} {{#_mdy}}{{ConcertStartDateTime}}{{/_mdy}} {{/concerts}}

All the dates from the concerts array are displayed as 12/31/1969 which I think is the value displayed when the date supplied to strtotime is not valid.

I added a line to the php script that assembles the data to execute the same command as in the helper ($concerts is the array supplied to the mustache renderer:
echo date("m/d/Y", strtotime($concerts[0]['ConcertStartDateTime']))
and it displayed the correct date.

Other values from the concerts array are displayed correctly.

What am I doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant