Skip Navigation

[Resuelto] date custom field has value of 1970/1/1 when Importing from a csv file

This support ticket is created hace 4 años, 12 meses. There's a good chance that you are reading advice that it now obsolete.

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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Etiquetado: 

Este tema contiene 19 respuestas, tiene 3 mensajes.

Última actualización por Christian Cox hace 4 años, 11 meses.

Asistido por: Christian Cox.

Autor
Mensajes
#1380955
TS_date.JPG

I am trying to: Get the right values for corresponding custom fields (created with toolset) when importing from a csv file, the other fields are alright, title, author, content, featured img. I have tried importing more than 5 times, but the date is still 1970-1-1 for all post.

Link to a page where the issue can be seen: enlace oculto

I expected to see: The date field should be 2019-06-06

Instead, I got: 1970-01-01

#1381213

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hello,

Thank you for getting in touch.

Could you let me know the value of at least 1 column in your CSV file that is related to the date?

Or you can send me a screenshot of the csv file so that I can see what you have in the date custom field column.

Thanks,
Shane

#1381293

Hi Shane,

The format is yyyy-mm-dd

Yes, the format of the date in the csv is different from the format in the toolset field, January 1, 1970.
Can you please tell me what format of the date is accepted in the toolset field?

#1381299

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hello,

I believe this is the issue.

Our Date fields store the dates as a timestamp meaning if you have a date "Tuesday, November 12, 2019" it will be "1573583124" as a timestamp.

So you would need to store your dates like this.

Thanks,
Shane

#1385187

Hi Shane,

I can import the correct date with timestamp, thanks.

On a related subject, how do I create a search for a certain range of date? eg all posts published in the last 2 weeks? or all posts after 2019/1/1.

I have tried "greater than", "smaller than", and "between" with the DATE format, but the result doesn't make sense to me.

Thanks,
David

#1386009

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Delia,

Is it a frontend search or is it that you want to filter your posts for the last 2 weeks ?

Please let me know.

Thanks,
Shane

#1386499
search_view_blog_date_example.jpg

Hi Shane,
It's a frontend search.
I have attached a screenshot of what I want to achieve, it's under the "filter by timeframe" in the screenshot.
Thanks.

#1387053

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Delia,

Thank you for the clarity.

Unfortunately no there isn't a way to do this with our plugins.

We can only filter by using the datepicker and not the way you have it like on your screenshot.

For this to work you will need to write some custom code to get this working.

I may have a solution for this if you would allow me to have admin access to this search that you have setup.

Thanks,
Shane

#1387323

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Private fields

#1389021

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hello,

Can you let me know once this is done so that I can check on the search ?

Thanks,
Shane

#1389361

Hi Shane,

You can check on the search now, thanks.

#1391279

Hi Shane,

Are you still assisting me?

#1391829

Hi, Shane is on holiday this week and I'd like to continue assisting you with this ticket. I tried logging in using the credentials you provided, but I get an invalid password error. Can you double-check the login and provide updated credentials if necessary? I have activated private fields again for your next reply.

#1392711

Okay I'm not exactly sure what Shane had in mind, but I was able to create a custom select filter with multiple date options:

[wpv-control-postmeta field="wpcf-blog-date" type="select" url_param="wpv-wpcf-blog-date" source="custom" display_values="Any,Past 3 Years, Past 5 Years" values="-9999999,[tssupp-strtotime str='3 years ago 0:00:00'],[tssupp-strtotime str='5 years ago 0:00:00']"]

I updated the query filter to show results from dates "Any", "Since 3 years ago at 0:00:00", and "Since 5 years ago at 0:00:00". I had to disable the View setting "only show available options for each input" to make this custom filter work. You can see the results update in the View now, and the dates seem to be accurate. If you'd like to adjust those values, you can see how they are configured in the shortcode above. I created a custom shortcode that converts strings like "3 years ago at 0:00:00" into timestamps. I added that in Toolset > Settings > Custom Code, but you could move that into your child theme's functions.php file if you'd prefer to have it there. I also registered tssupp-strtotime in Toolset > Settings > Third party shortcode arguments so it can be used in the filter shortcode.

One strange thing I noticed is that the URL of the page is updated incorrectly after I submit a search. Is this something you have noticed before, or do you have any idea why this would be happening? If not, I need to do some more in-depth investigation here because the updated URLs are not correct. They point to the AJAX request URL, not the updated page URL.

#1393217

Hi Christian,

Thank you for your help, I will read through the changes you have made and ask you if I have any questions.

Regarding the URL updating incorrectly after submitting a search, I have no idea why it is happening, but I when I seperate the search form and the result, there are 2 options to choose from "the search result will display in the same page as the search form" and "the search result will display on another page", and I selected the "same page" option, I don't know if there is any relation to this problem.