Signature
apply_filters( 'mam_gd_date_format', string $format );
| Parameter | Type | Description |
|---|---|---|
$format |
string | A PHP date() format string. The default is sourced from the mam_gd_date_format option, falling back to 'M d'. |
Returns: string — the format to use. You must return a non-empty string.
Purpose
Customises how the plugin renders date strings on event cards, calendar entries, and the start_end_dates / start_end_times fields on the listing detail screen. The same format is used wherever a date is rendered for the app — there is no per-card override.
When it runs
Three call sites:
mam_geodirectory_content::get_data_for_app()— once per request, before the per-listing loop.mam_gd_content_blocks::mam_content_section_events— once per event card on a listing’s events section.mam_gd_content_blocks::*— when building a card’sdate_label.
Each call site reads mam_gd_date_format option as the default and lets the filter override.
Default values
'M d'
The admin can change the default under Mobile App Manager → Geodirectory → Settings → Date format for layouts and cards?. The dropdown offers M d, Y, d M, Y, Y-m-d, d-m-Y, Y/m/d, d/m/Y, m/d/Y.
Examples
Always use ISO format
add_filter( 'mam_gd_date_format', static fn () => 'Y-m-d' );
Use the WordPress site default
add_filter( 'mam_gd_date_format', static fn () => get_option( 'date_format' ) ?: 'M d' );
Per-locale formatting
add_filter( 'mam_gd_date_format', 'my_app_locale_date_format' );
function my_app_locale_date_format( $format ) {
$locale = determine_locale();
if ( str_starts_with( $locale, 'fr' ) ) {
return 'd/m/Y';
}
if ( str_starts_with( $locale, 'ja' ) ) {
return 'Y-m-d';
}
return $format;
}
Gotchas
- Format applies to every event display. A short format like
'M d'truncates years;'M d, Y'adds them back. Pick one that’s unambiguous for your audience. - Runs frequently. Multiple call sites fire this filter many times per request. Keep the callback constant-time.
- Locale-sensitive formats. PHP’s
date()doesn’t localise month names; usewp_date()upstream if you need that, or transform the rendered string after. - Empty return breaks rendering. Always return a valid
date()format string.
Verification
This article was last verified against:
- Plugin:
mam-geodirectoryv2.1.5 - Source:
content-classes/local-app-geodirectory-v2-class.php(line 498) - Source:
includes/mam_gd_content_blocks.php(lines 269, 778)
Re-verify whenever the call sites are renamed, the option key (mam_gd_date_format) changes, or the dropdown’s choice list in the admin settings page changes.
Related articles
- Plugin: mam-geodirectory
- Listing detail content sections
- Mobile listing data shape
- Hook: mam_geodirectory_event_card
Metadata
| Field | Value |
|---|---|
| Article type | Hook Reference |
| Plugin slug | mam-geodirectory |
| Applies to plugin version | 2.1.5+ |
| Category | Extending MAM Suite |
| Hook type | filter |
| Audience | PHP developer |
| Last verified | 2026-05-01 |
