Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Lyne Berro

Exporting date published shows time

How can i not have the time shown when exporting the date published field? as pictured here

https://i.imgur.com/u7Insy8.png

2 years, 3 months ago
Stefan van den Dungen Gronovius
Developer

We decided to export the date format that is returned by the Post in WordPress.
If you want to change this for export, you can use the hook ac/export/value.
The snippet will look something like this:

add_filter( 'ac/export/value',function( $value, AC\Column $column, $id ) {
	if( $column instanceof \ACP\Column\Post\DatePublished ){
		$value = get_the_date( 'Y-m-d', $id );
	}

	return $value;
}, 10, 3 );
2 years, 3 months ago
Lyne Berro

Also why is the date format different after export? we show YEAR first on wpadmin but the CSV shows differently

https://i.imgur.com/YNeyiS3.png

2 years, 3 months ago
Tobias Schutter
Developer

When exporting a ACF Date field type you should get the correct date. ACF does not store the time. Maybe you have used the Date Time field instead of a Date field. Could you check this?

2 years, 3 months ago
Lyne Berro

THank you, however we are having the same issue with an ACF field pictured below, please advise how to change that one too

https://i.imgur.com/llu6WYV.png

2 years, 3 months ago
Stefan van den Dungen Gronovius
Developer

Did you try the snippet I send you earlier?
It is good to know that our export feature does indeed not export the way you have setup your column.
The date published column is always exported as the WP_Post returns the date.
The ACF Date column should always export in ‘Y-m-d’.

The snippet above will remove the time from the date in your export for the ‘Date Published’ column. I don’t understand why the ACF date is not correct in your Excell sheet. Just to be sure, can you check the raw CSV file and see if the date is also in the wrong format? Maybe the date is being corrected when opening the file in Excel.

And do you not have any custom hooks in your website related to our export feature?

2 years, 3 months ago

You must be logged in to reply to this topic.