from_date
Reads a date out of a string using the same PHP-style layout the date modifier writes with, so `June 26, 2026` piped through from_date:'F j, Y' becomes a real time.Time that a date column can take.
Without it a template has to rewrite a month name by hand, which is a chain of a dozen replacements that no reader can check.
The value has to match the layout in full, separators included, and any character the layout language does not name is matched literally. A value carrying its own offset keeps it, and anything else is read as UTC, so a date-only value lands on midnight UTC rather than on whatever zone the process happens to run in.
A layout given here is honored exactly and never second-guessed. A value that does not match it is an error. Returning the zero time instead would send January 1, year 1 downstream as if the store had really said so.
The layout is optional. With none given the value is read as it comes, through the forms a printed date usually arrives in, ISO 8601 and RFC first, then the ones a month name spells out, then the numeric ones. A numeric value whose day and month could be either way round, such as 03/04/2026, is refused rather than guessed, and a layout settles it.
stringstringtime.Timestringno argumentstime.TimeReads a date out of the string a store printed, using the same layout language date writes with, so a month name becomes a real date rather than a chain of replacements.
Given
{"printed": "June 26, 2026"}Template
{{ printed | from_date:'F j, Y' | date:'Y-m-d' }}Result
2026-06-26Reads a date and a time together, where d is the zero-padded day, m the zero-padded month, H the 24-hour hour, and i the minute.
Given
{"printed": "14/03/2024 09:30"}Template
{{ printed | from_date:'d/m/Y H:i' | date }}Result
2024-03-14 09:30:00Reads a date with no layout given, working through the forms a printed date usually arrives in.
Given
{"printed": "26 June 2026"}Template
{{ printed | from_date | date:'Y-m-d' }}Result
2026-06-26Reads a numeric date that only one reading fits, since 25 can only be the day.
Given
{"printed": "25/12/2026"}Template
{{ printed | from_date | date:'l, F j, Y' }}Result
Friday, December 25, 2026Refuses a numeric date that reads as a real date either way round, since a layout says which one it is.
Given
{"printed": "03/04/2026"}Template
{{ printed | from_date | date:'Y-m-d' }}Result
error: failed to render template: failed to render variable token 'printed': modifier "from_date": function failed to apply: failed to read date "03/04/2026" without a layout (pass one such as 'd/m/Y'): day and month could be either way round
2026-04-03