How to Change Date and Time Notations?

By default, the date and timepicker in GD follows the 12-hour notation, wherein it goes from 0-12 pm and 0-12 am. You can, however, change it to 24-hour notation with the help of a simple code snippet. 

Don't forget to also change your WP settings to 24hr time in WP Admin - Settings - General

Changing Date and Time Notation

Simply use the following code snippet to change the date and time notation to 24-hour model: 

/**
 * Event times 24hr timepicker.
 */
function gd_snippet_event_times_24hr( $attrs = array() ) {
	$attrs['data-alt-format'] = 'H:i';
	$attrs['data-time_24hr'] = 'true';

	return $attrs;
}
add_filter( 'geodir_event_aui_start_end_time_attrs', 'gd_snippet_event_times_24hr', 11, 1 );

/**
 * Business Hours: Use 24 hour time format in time picker.
 */
function gd_snippet_business_hours_24hr_params( $params ) {
	$params['time_24hr'] = true;
	return $params;
}
add_filter( 'ayecode_ui_calendar_params', 'gd_snippet_business_hours_24hr_params', 11, 1 );

function gd_snippet_business_hours_24hr_format( $time_format ) {
	return "H:i";
}
add_filter( 'geodir_business_hours_input_time_format', 'gd_snippet_business_hours_24hr_format', 11, 1 );

We recommend using the Code Snippets plugin for adding code snippets to your site. 

Furthermore, if you wish to change text strings and further customize or localize GD, you should consider going through our guide to translating or localizing GeoDirectory

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us