To explain the title, is it possible to use the date that is set in a Date Time Picker (Aanvang) in a Time Picker (Eindtijd)?
The current set up is just a Time Picker which looks easy to handle for the end-user:
Since $timeformatstring only picks the time from the Time Picker, it actually takes the date of today.
The easiest solution would be to create another Date Time Picker, but this is used already in another field (field B), where another Date and Time can be set.
This is the code that’s running things now:
$startdatum_tijd = get_field('aanvang', $post->ID, false);
$startdatum = date_i18n('j F Y', $startdatum_tijd);
$einddatum = get_field('einddatum', $post->ID, false);
$eindtijd = get_field('eindtijd', $post->ID, false);
$dateformatstring = "D. j F Y: H:i";
$timeformatstring = "H:i";
$unixtimestamp_start = strtotime($startdatum_tijd);
$unixtimestamp_endtime = strtotime($eindtijd);
$unixtimestamp_otherenddate = strtotime($einddatum);
<div class="article-date">
<?php if($einddatum){
$eind = date_i18n($dateformatstring, $unixtimestamp_otherenddate);
} elseif($eindtijd && $startdatum_tijd > $date_now) {
$eind = date_i18n($dateformatstring, $unixtimestamp_endtime);
} else {
"";
} ?>
<span style="font-weight: 200;"><?php echo date_i18n($dateformatstring, $unixtimestamp_start); ?> uur - <?php echo $eind;?> uur</span>
</div>
I tried to cheat and output the time, using:
elseif($eindtijd && $startdatum_tijd > $date_now) {
$eind = date_i18n($timeformatstring, $unixtimestamp_endtime);
}
but that that failed of course, although not visible in the frontend. Switching back to:
$eind = date_i18n($dateformatstring, $unixtimestamp_endtime);
revealed the problem and the actual output is like this:
As you can see, it picks today’s date, 13 oktober.
What I would like to achieve is this, where Eindtijd uses the date from Aanvang, so in this case 10 november, where it is hidden in the front end since it’s the same day.
I’ve no clue how to do this… Thanks in advance and sorry for the messy look of this thread!