0

I'm writing my own theme for All in One Event Calendar using the Twig environment they have set up. I'm trying to check if the date for an event is within so many hours of the current time and have written my own function to do so, but I'm having trouble getting what I want to be passed.

If I do this:

{{event.get('start')}}

Twig prints a timestamp - super!

But if I do this:

{% if expired(event.get('start')) %}

and print the argument from the expired function, I find that it received a giant Ai1ec_Date_Time Object instead of the timestamp. How can I get the output from the first example passed into my function in the second example?

Ethan C
  • 1,408
  • 1
  • 14
  • 26

1 Answers1

0

Figured this out. Used the Ai1EC_Date_Time class method __toString() on the argument within the expired function, so I ended up with something along the lines of:

function expired($date) {
    $time = strtotime($date->__toString());
    ...
}

Kind of an obvious solution in retrospect, but hopefully this will help someone out in the future.

Ethan C
  • 1,408
  • 1
  • 14
  • 26