Using dateTime() or dateTimeUTC() with variable

I was wondering why the dateTime() and dateTimeUTC() functions only except literal integers and no variable integers? E.g. dateTimeUTC(2016) works; however, if I have an object with variable year(integer) then dateTimeUTC($object/year) does not work. This limitation also does not become apparent from the documentation.
2 answers

I think that dateTime() and dateTimeUTC() are programmed to create final static variables and are therefore not meant to "calculate" dates. I used a workaround for the same problem by first initiating a date using dateTime() and next adding years using addYears(). I agree this is not as nice as desired, so you might want to file a ticket anyway.


I'm running into the same problem. I would be interested in a solution or a proper workaround to incorporate dynamic variables in DateTime functions.