John Davidson

php - compare date today to event date

0 comments
Message:


I am trying to create a function in php where i check for the events date and if it less than todays date, then show no events. And if it is greater than todays date, display the date.


This is my php function


function todays_date($date)
{
$date_now = time();

}
function event_start_date($id)
{
$startDate = strtotime(get_field('event_start_date', $id));
$date = date('U', $startDate);
return $date;
}


and the in twig im checking to see if the dates are greater than one another in order to do something else


    {% set date = function('event_start_date', item.id)|date('M d') %}
{% set today = function('todays_date')|date('M d') %}
{% if date < today %}
<p>No events found.</p>
{% else %}
<p class="date">{{ date }}</p>

im not sure what i am doing wrong.



My Answer:
> today %}

No events


{% else %}

{{ date }}


{% endif %}

Rate this post

4 of 5 based on 4054 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us