Using Drupal 9.3.22, Calendar Link 2.1.4. It works greate for Date and Time field. But I am using the Datetime Range field. In the twig template node--page.html.twig, I added this:
{% set link = calendar_link('google', node.title, node.field_date_range.value, node.field_date_range.end_value, node.body) %}
<a href="{{ link }}">Add to calendar</a>
I get the error: Could not get date and time from input value 2023-01-16T07:14:26 ()
The correct start date is shown in the error.
I found
in this post
β¨
Views support
Fixed
, they are using split to separate the start and end date. I could not get split to work.
This works, but the time is 12am for both start and end time
{% set link = calendar_link('google', node.title, node.field_date_range.start_date, node.field_date_range.end_date, node.body) %}
<a href="{{ link }}">Add to calendar</a>
I tried to add the time, but get error - Could not get date and time from input value Monday Jan 16 2:14 AM ()
{% set link = calendar_link('google', node.title, node.field_date_range.start_date|date(format='l M j g:i A'), node.field_date_range.end_date|date(format='l M j g:i A'), node.body) %}
<a href="{{ link }}">Add to calendar</a>
I tried to convert the date to ISO 8601
I get the error Could not get date and time from input value 2023-01-16T02:14:26-05:00 ()
{% set link = calendar_link('google', node.title, node.field_date_range.start_date|date("c"), node.field_date_range.end_date|date("c"), node.body) %}
<a href="{{ link }}">Add to calendar</a>