[Resolved] How to Import Date to a Date Picker using WP All Import PRO
This thread is resolved. Here is a description of the problem and solution.
Problem:
The customer asked how to import the date value in the Toolset's date type field, using the WP All Import PRO plugin.
Solution:
Guided that the Toolset date type field, stores the date/time value in the UNIX timestamp format, and while importing the data in it, the same format should be used.
Relevant Documentation:
n/a
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.
Our next available supporter will start replying to tickets in about 7.52 hours from now. Thank you for your understanding.
I am trying to import a date into a date picker so I can use the range feature to filter the data.
Currently I am using the code below to convert the data into what I assume is the right format.
[date( "Y-m-d H:i:s", strtotime( str_replace("/",".",{approvaldate[1]}) ) )]
Using the preview in the editor, I am seeing my original date:
Example:
"<approvaldate>9/2/2021</approvaldate>"
Thank you for contacting us and I'd be happy to assist.
The Toolset date type field, stores the date/time value in the UNIX timestamp format, and while importing the data in it, the same format should be used.
This means that in your code, you'll replace the format string "Y-m-d H:i:s" with "U":
( ref: hidden link )
Thank you for the assistance. That didnt seem to do the trick though but I realized I needed to remove the string replace to get the UNIX timestamps right.
[date( "U", strtotime( {approvaldate[1]} ) )]
Now when I run the import, I get the following (example)
Input Date:
9/24/2021
Unix conversion:
1632441600
That is correct but in the date picker, it is displaying as follows.
July 19, 1600
(Attached is a screenshot).
Do I need a separate field for the displaying the date in the view that isnt translated?
I've checked the edit screen of all 34 "Transparency Reports" posts on the website and they all are showing the "Approval Date" field value correctly.
I also didn't see any abnormality in the date picker either and it follows the default behavior of starting from the current date.
This suggests that the import process for these date-type fields was completed successfully. I'll recommend checking the edit screen of all those posts again, after clearing the browser's cache.
If you still see something out of place, please share the exact steps to see it.
> The date shows but it doesnt work with the date picker filter on my view:
> My main goal is to get the date range picker working though.
- I'm not sure what settings you used to add the date range filter fields in the view "Transparency Report" earlier.
But, I've removed the existing date field filter for the "Approval Date" field and added a new one and it seems to be working now.
( screenshot of the settings I used: hidden link )
> Also, when you click the date picker on the edit page, it doesn't show the same date on the calendar as the one shown.
- As I mentioned in my previous reply, that is the normal/default behavior. When you'll open the date picker in the post edit screen to select a new date, it starts from today's date and not from the existing/selected date in the field.
( example screenshot from my test website: hidden link )
Great, it looks like I was setting up the date range selector incorrectly.
I was setting the Filter Comparison to DATE or DATETIME and it looks like I needed to set it up as a NUMBER instead. Weird to me but it works! Thank you.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.