Home › Forums › ACF PRO › Compare 2 different time pickers › Reply To: Compare 2 different time pickers
Hi @zilveer
You should be able to use the acf/validate_value
hook. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/acf-validate_value/. It should be something like this:
add_filter('acf/validate_value/name=time_start', 'my_acf_validate_time', 10, 4);
function my_acf_validate_time( $valid, $first_time, $field, $input ){
// bail early if value is already invalid
if( !$valid ) {
return $valid;
}
// remove the ":" char from the time and set the value as int
$first_time = (int) str_replace(':', '', $first_time);
$second_time = (int) str_replace(':', '', $_POST['acf']['field_588425efcdf00']);
// compare the time
if( $first_time < $second_time ){
$valid = 'Start time should be after end date ';
}
// return
return $valid;
}
I hope this helps 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.