This works for me, starting with a string:
{% set yearbegins = '1 January ' ~ year %} // getting year from a url (dynamic route)
{{ yearbegins | date("U") }} // outputs the date in Unixtime
But, like you, I'm finding some unpredictability.
This works for me, starting with a string:
{% set yearbegins = '1 January ' ~ year %} // getting year from a url (dynamic route)
{{ yearbegins | date("U") }} // outputs the date in Unixtime
But, like you, I'm finding some unpredictability.