Skip Navigation

[Résolu] Custom field date is changed from January 9, 2017 to 20170109 on front end

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 32 réponses, has 2 voix.

Last updated by seanN-5 Il y a 4 années et 8 mois.

Assigned support staff: Minesh.

Auteur
Publications
#478249

Trying to understand the date format and where these items are set. In test site we were using the Custom post type, Advanced Custom Fields and Toolset. The Events were created manually.

In the production site:

Events are created in NEON CRM and downloaded to a xml file via api.
XML file is imported into Advanced Custom Fields via plugin WP All Import and Events are created based on import.

As far as dates being set here is what I have:

Date Setting in WordPress is set to: Ymd
Date setting in Advanced Custom Field start_date field is set to: Ymd
WP All Import does not set a date. It just pulls info over from xml file and places in custom post type advanced custom fields.

In the XML file looks like date is set to: 2017-01-14
But once its placed in the start_date field in a event post it is set to: 20170114

-----

Any idea of where the date setting is off?

Thank you.

#478254

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - Please check this post date:
=> hidden link

The date is showing wrong. Please do something so that right date is imported to start and end date field and then I'll check further.

#478263

On the post you referenced I am seeing:

Start Date: 22221212
End Date: 22221212

These are the dates set in the NEON CRM system. December 12, 2222. These are internal post items on their CRM that are pulled over for now. Still trying to remove them from the api.

But if we look at the format of the two dates they are Ymd.
--

#478272

I went ahead and changed the status of two of the posts showing to Draft, and now only one event is showing. Seems like currently we're only pulling the events with a year of 2222.

As a test I changed another post to have a start year of 2222, and its showing.

#478276
test-vs-production-fields.jpg

Here is a screenshot of the test vs production fields as displayed in a custom post type event.

Format of start date and time seem to be the same.

#478288

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

That's good - Could you please setup few after events just like you did with test site so that we are sure that we are getting correct results.

#478298

Ok I created four After events.

1 & 2 I manually added in date and time.

3 & 4 I set the date and time throughs Date and Time picker.

#478300

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

But I can see only two events on page. I think events created using date picker is not displaying. That's why this is a mess. Which events should be considered?

#478301

Its set to show only three. I'm going to increase that.

I set after event 2 to draft and after event 3 showed.

#478302

I have it set to show 10 events.

Only events showing are those that have a start date of 22221212 or new events created.

#478306

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Great - thanks.

Could you please confirm that this view output returning expected results now?
=> hidden link

Do you want me to check any other view?

#478309

I added a new event called Before Event 1 with a start_date of Dec 21. It did not show (as expected). Next I changed the date to Jan 21 and it did show (as expected). Then changed it back to Dec 21, 2016 and once again not showing (as expected).

So new events created appear to be working.

Events that are imported in seem to be having the problem. But to test I'm going to delete all of the imported events and re-import them.

Can you see any difference in the start_date format between and item imported in and one created manually?

Manual: hidden link

Imported: hidden link

#478314

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please check your database and check "start_date" postmeta key value for both the posts : Manual and imported.

I see that both posts have different values for "start_date" postmeta. It should be imported in the format in which its currently working for now.

#478336

OK. I can see that in the database its storing things differently. Manual post is 20170128 while imported posts are using the dash - 2017-01-28.

Next step is to figure out how to change the start_date on import to the database from Y-m-d to Ymd.

#478553

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - exactly. I think then automatically all things work. Please let me know if you need further help from this end.