Skip to content

Instantly share code, notes, and snippets.

@altoin
Created August 28, 2024 06:58
Show Gist options
  • Save altoin/bab99007bc46845d2e802df94dc9c136 to your computer and use it in GitHub Desktop.
Save altoin/bab99007bc46845d2e802df94dc9c136 to your computer and use it in GitHub Desktop.
Change the return format for date and time in lookup field.
<?php
add_filter( 'frm_filtered_lookup_options', 'format_date_display', 10, 2 );
function format_date_display( $options, $args ) {
if ( $args['field']->id == 31427 ) { // change 20116 to the ID of the date field in the other form
foreach ( $options as $k => $option ) {
$option =new DateTime($option);
$options[$k]= date_format($option,"m/d/Y");;
}
}
return $options;
}
add_filter( 'frm_filtered_lookup_options', 'format_time_display', 10, 2 );
function format_time_display( $options, $args ) {
if ( $args['field']->id == 31428 ) { // change 31428 to the ID of the time field in the other form
foreach ( $options as $k => $option ) {
$options[$k]= date("h:i a",strtotime($option));
}
}
return $options;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment