Skip Navigation

[Resolved] date fields doesn’t show data if they are before 1950

This thread is resolved. Here is a description of the problem and solution.

Problem:

I am using the last beta version of types 3.0-b1, the types custom date field.

If the data is like: 28/01/2018 --> data is shown

but if the data is like 28/01/1940 --> no data or strange data like 1/5/9715

Solution:

Here is the hot fix:
Edit file of Types beta plugin, file \application\models\field\type\date\date.php, replace line 67, from:

if ( preg_match( '~^[1-9][0-9]*$~', $value ) ) {

To:

if ( preg_match( '~^-?[1-9][0-9]*$~', $value ) ) {

Relevant Documentation:

This support ticket is created 6 years, 7 months ago. 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.

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/Hong_Kong (GMT+08:00)

This topic contains 8 replies, has 2 voices.

Last updated by Luo Yang 6 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#630765

NOTE: I am using the last beta version of types, views, layouts and cred because my needs on the new relationships. This doesn't happen in the stable version.

I tried disabling all no necesary plugins, the same result.

I am trying to:

in a view, I have a <td> with a types field of date. The strange is:

If the data is like: 28/01/2018 --> data is shown
but if the data is like 28/01/1940 --> no data or strange data like 1/5/9715

I tried showing raw timestamp and also formatted date, the same result

I can provide login to a testing enviroment where you will reproduce the problem. So please, give me a private reply if you want.

#630848

Hello,

Thanks for the feedback, I can duplicate same problem with Types plugin 3.0-b1, have escalated this thread to our 2nd tier supporters, hope there will be a fix soon, you can also subscribe to our blog to get the updated news:
https://toolset.com/blog/

#630854

This is why I provided a testing enviroment, because I need a solution ASAP 🙁

There is any estimated time?

Regards

#630887

Since you are using Beta version of Types plugin, that means there might be some bugs in the beta version plugin, and I have reported it to our developers, but I am not sure when it will be fixed, in most case, such kind of bugs will be fixed in the next version of Types beta plugin.

And I will update this thread if there is anything news.

#631650

I can confirm is an UNIX posix time bug

Types works with Posix Unix TIme. This time counts from 1/01/1970. I take a look to types beta plugin to see if I found where exactly in the code occurs but I didn't found anything.

Any update from 2nd tier supporters?

REgards

#631741

Here is the feedback from our developers, it will be fixed in next version of Types beta plugin. Again, I am not sure when will it be released.

#631744

Here is the hot fix:
Edit file of Types beta plugin, file \application\models\field\type\date\date.php, replace line 67, from:

			if ( preg_match( '~^[1-9][0-9]*$~', $value ) ) {

To:

			if ( preg_match( '~^-?[1-9][0-9]*$~', $value ) ) {

And test again.

#631809

Yes, it was the preg_match value, now works OK. Thanks for updating this

Regards

#632160

You are welcome