Skip Navigation

[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 0.36 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 7 replies, has 2 voices.

Last updated by Project Weblife 1 year, 10 months ago.

Assisted by: Waqar.

Author
Posts
#2420269

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>"

Converts to

"2021-02-09 00:00:00"

I was using this solution.
https://stackoverflow.com/questions/64254986/wp-all-import-pro-function-to-change-date-and-time-format-from-imported-csv

But in the backend, the date picker field shows empty when I edit the node.

Any help is appreciated. Thank you!

My View: hidden link

#2420445

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

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 )


[date( "U", strtotime( str_replace("/",".",{approvaldate[1]}) ) )]

I hope this helps and let me know if you need any further assistance around this.

regards,
Waqar

#2421093
Screen Shot 2022-07-19 at 2.28.43 PM.png

Hello Waqar,

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?

#2421523

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back and sorry about missing the "str_replace" part.

To troubleshoot this, I'll need to see how the data of these imported custom fields are showing in the back end.

Can you please share temporary admin login details, along with the example of a few imported posts with this date field?

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

#2423171

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing the admin access.

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.

#2423177

Hey Waqar,

The date shows but it doesnt work with the date picker filter on my view:

hidden link

Also, when you click the date picker on the edit page, it doesnt show the same date on the calendar as the one shown.

My main goal is to get the date range picker working though.

#2423201

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

> 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 )

#2423235

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 Toolset client and need related help, please open a new support ticket.