I have a code block for giving the datetime of an event from a custom field type.
Therefore I would like to add the html tag “time” to the code. But how to do this? There is no html tag for the code block in the settings.
There literally is an html tag called ‘time’. It’s semantic. From MDN docs.
I may be misunderstanding; when you say code block, I assume you mean you’re placing the code element and have custom code running within it?
I have a code element block that runs the following:
<?php
$post_id = get_the_ID();
$start_time = get_post_meta( $post_id, '_EventStartDate', true );
$start_time_local = date( 'Y-m-d H:i:s', strtotime( $start_time ) );
$day = date( 'j', strtotime( $start_time_local ) );
$month = date( 'M', strtotime( $start_time_local ) );
$year = date( 'Y', strtotime( $start_time_local ) );
echo '<time class="muted-background" datetime="' . $start_time . '">' . PHP_EOL;
echo '<span class="day">' . $day . '</span>' . PHP_EOL;
echo '<span class="month">' . $month . '</span>' . PHP_EOL;
echo '<span class="year">' . $year . '</span>' . PHP_EOL;
echo '</time>';