Change the way dates are output in the analytics graph

When I add the Google Analytics output to the report, it outputs a graph that I don’t have any control over. The only thing I really want to change is how the dates are shown. It is D/MM instead of MM/D which is more natural to the States. Typically we do MM/DD/YYYY but in shorter form usually MM/DD. The report is D/MM and it always trips me up.
Is 1/12 January 12th, I would assume so at first glance. But no it’s December 1st. I don’t know why they did it this way but if there is a way to change the format, I would love to do it!

It’s maddening that despite the ISO having fixed the date format problem 33 years ago with ISO-8601, we still are plagued by people who can’t let go of outdated and confusing date formats.

There is no chance of confusing 2021-01-12 with 2021-12-01.

My only ask is that if work is done to permit customizing date formats, be sure to make ISO-8601 formatting an option.

Hi Zack,

first, let me apologize for the long delay with this topic.

It is possible to customize the date format, please try with the following filter in the PHP section of the Custom Dashboard extension:

add_filter( 'mainwp-reports-ga-chart-format-date', 'mainwp_custom_gachart_date_format', 10, 3 );
function mainwp_custom_gachart_date_format( $format_date, $m, $d ) {
	$format_date = $m . '/' . $d . '.|';
	return $format_date;
}

Thanks for the suggestion.

I added it using the Custom Dashboard plugin, it didn’t do anything.

I downloaded the mainwp, mainwp-google-analytics-extension, and mainwp-pro-reports-extension, I searched through all of them for this filter “mainwp-reports-ga-chart-format-date” but didn’t find it.

Where is this filter? Where does it come from? Do I need a different version of the analytics plugin or something else?

Thanks

You need the Custom Dashboard Extension

Hi Zack,

thanks for getting back to me.
I thought you are using the Client Reports extension, not Pro Reports.
Please check PM, I sent you an update for the Pro Reports extension that will work with the code I sent earlier.

Thanks!

Will the filter remain for the next release? Will the changes be erased when the plugin updates again?

Hi Zack,

we will include the filter in the next official release so you can update your extension when the time comes.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.