What you did wrong here is the part date('d', $rem_days)
.
When you use something like that, if you have the number of days more than one month, the function date()
with ignore that and only count the number of days. So for example, when the duration is 1 month and 14 days, it will instead show 14 days.
You can fix this by replacing date('d', $rem_days)
with floor($remaining_time/86400)
.
The complete code should be:
$event_date = strtotime( get_field( 'event_date', false, false ) );
$curr_date = time();
$rem_days = $event_date - $curr_date;
if ( $rem_days <= 0 ) {
$event_msg = '<strong>Event Expired</strong>';
} else {
$event_msg = '<strong>' . floor( $rem_days / 86400 ) . '</strong> Days Remaining';
}