Convert basic date string to dateobject (no time in string)
SOLVE
Hi,
I'm have an issue. We have event posts that have basic single line text field. In that the content publisher is putting in the date like so (d-m-Y e.g. 03-09-2019).
I've tried to use strtotime to convert this string into a dateobject which I can then use to convert into reading somethign like 3 Sept 19.
I think the issue is strtotime doesn't like that there's not time e.g.
{% set edate = post.widgets.event_date.body.value|strtotime('d/m/Y') %}
<p>{{ edate|datetimeformat('%e') }}</p>
As with most of my post(lol)…I'm no expert, but I gave it a shot!
It looks like your "strtotime" arguments are formated incorrectly.
As per the docs your year should be labeled as "yyyy", month as "MM", and day as "dd". All separated by "-". The user's input should be formated in this way as well.
As with most of my post(lol)…I'm no expert, but I gave it a shot!
It looks like your "strtotime" arguments are formated incorrectly.
As per the docs your year should be labeled as "yyyy", month as "MM", and day as "dd". All separated by "-". The user's input should be formated in this way as well.