Date Format

Closed
ImportWP Pro - WordPress XML & CSV Importer ImportWP Pro - WordPress XML & CSV Importer April 01, 2022
Login to reply
James Collings Support Agent
4 months ago

By replacing the value : {2}

with: [str_replace(",", ".", "{2}")]

this will convert 8,7 to 8.7 and should allow you to use the acf field (as the acf field adds extra custom fields behiend the scenes)

Rafael Tasca
4 months ago

I see, thank you very much.

I've found out another issue that it might be related to the same problem as ACF treats date:

I was importing to my field of weight a number, using the raw field. So it registered correctly a number, for example "8,7".

When I changed to the proper field ACF it ignores the "," and it imported for example "87". Probably because ACF was expecting "." as a decimal separator, right?

It doesn't bother me right now, I will keep the raw field. But I guess it would be a nice addition to the plugin in the future if we could choose the format to import so these problems doesn't happen, like the date format.

James Collings Support Agent
4 months ago

I think the date stored in acf data does not relate to those settings, they are how the data is formatted when you save and how it looks on your Admin interface.

Rafael Tasca
4 months ago

Funny that in my ACF configuration I've set the Display Format and Return Format in my Date Picker Field to be d/m/Y. Don't know why it didn't worked normally. Would that be some error related to ACF plugin that I should discuss with them?

But with your custom solution, it worked! Thank you! Once again a great support, one of the best I ever had with premium plugins, exceeding all expectations. Thank you very much.

James Collings Support Agent
4 months ago

because that date is returned it suggests that the date format being entered is not liked by acf as you data is d/m/Y , we can use a custom method to fix this and transform the date into a more generic format.

I have attached a plugin, once activated will add a custom method to allow transformation of your date.

replace custom field value:
{5}


with:
[iwp_ticket_34849_date_modifier("{5}")]

this will change the preview to:
2016-08-16

and if you import acf should accept that date format.

Rafael Tasca
4 months ago

Oh I didn't had that Addon. I thought it was already included in WP Import Pro.

Ok, I installed it. It shows me the fields as you mentioned "ACF - custom_field". I imported again with my correct field but still got an error on date, now it imports as 01/01/1970 date.

I will try out another tests.

James Collings Support Agent
4 months ago

The custom fields dropdown hows custom fields that are found relating to existing objects on your site, each prefixed by default with "RAW" to say it is not related to an importwp addon.

when Importwp addons add custom fields to the dropdown list, each custom field it adds is prefixed with the name of the addon.  e.g. ACF - custom_field

James Collings Support Agent
4 months ago

Just to confirm, do you have the importwp acf addon activated: https://www.importwp.com/integrations/advanced-custom-fields/

Rafael Tasca
4 months ago

Oh sorry. I don't know what are 'Raw Fields'.. all it shows to me are raw fields.

There is another one _data_de_producao. I tried to import and update with that one. But the date didn't changed.

James Collings Support Agent
4 months ago

Hi Rafael,

It looks like you have the "Raw Field" version of the custom field, not the "ACF" prefixed version, can you switch to that and rerun the import.

The importer will attempt to switch your date to the correct format, if that fails let me know then we can use a custom method to modify the date before being inserted into the acf data.

James Collings Support Agent
4 months ago
Thanks for creating a ticket! We'll get back to you as soon as we are back from vacation.
Rafael Tasca
4 months ago

Hello!

My ACF Date Picker field is in format dd/mm/yyyy and that is how I show date in my website. My spreadsheet is also in this format.

I noticed that when importing the plugin tries to do mm/dd/yyyy. Every row that doesn't fit in this format gets wrong date (it gets the date of today).

I couldn't find anything in Docs about this and no options to change in the plugin. But the preview even shows me the correct format date of my spreadsheet.

Is there a solution for this in the import?

Thank you!