Problem with Date Field when using Pre-1900 dates

I’m having problems with the date picker when I attempt to select a date before 1900 - it reverts to Jan 1, 1970.

This is working on a my beta server, but not on the live server, so I expect it’s a PHP configuration problem, or maybe it’s missing a module. Unfortunately, the client’s hosting account is with GoDaddy, and the only config settings seem to be choosing between PHP 5.3 and 5.4.

Here’s the main PHP Info for each:

beta (working):

PHP Version 5.6.16

System	Linux serv01.siteground212.com 3.12.18-clouder0 #1 SMP Wed Dec 9 10:11:24 EET 2015 x86_64
Build Date	Nov 26 2015 14:43:30
Configure Command	'./configure' '--prefix=/usr/local/php56' '--mandir=/usr/man' '--with-config-file-path=/usr/local/php56/lib' '--with-config-file-scan-dir=/usr/local/php56/etc' '--with-pear=/usr/local/php56/pear' '--with-iconv' '--disable-ipv6' '--with-openssl=/usr/local/openssl' '--with-zlib' '--enable-bcmath' '--with-bz2' '--enable-calendar' '--with-curl' '--with-db4' '--with-dbm' '--with-enchant' '--with-curlwrappers' '--enable-exif' '--enable-ftp' '--with-kerberos' '--enable-intl' '--with-pcre-regex' '--with-libdir=lib64' '--with-gd' '--with-pspell' '--with-libedit' '--with-readline' '--with-jpeg-dir' '--with-png-dir' '--with-zlib-dir' '--with-xpm-dir' '--with-freetype-dir' '--with-t1lib' '--enable-gd-native-ttf' '--with-gettext' '--with-imap' '--with-imap-ssl' '--with-ldap' '--with-ldap-sasl' '--enable-mbstring' '--with-mcrypt' '--with-mhash' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--disable-mysqlnd' '--with-icu-dir=/usr/local/icu4c' '--with-mysqli=/usr/bin/mysql_config' '--enable-pcntl' '--enable-sysvmsg' '--enable-sysvsem' '--with-pdo-mysql=/usr' '--with-pdo-pgsql' '--with-pgsql' '--enable-shmop' '--with-snmp=shared' '--enable-soap' '--with-tidy' '--enable-sockets' '--enable-wddx' '--with-xmlrpc' '--with-xsl=/usr/local/libxslt' '--with-libxml-dir=/usr/local/libxml2' '--enable-opcache' '--enable-zip'
Server API	CGI/FastCGI
Virtual Directory Support	disabled
Configuration File (php.ini) Path	/usr/local/php56/lib
Loaded Configuration File	/usr/local/php56/lib/php.ini
Scan this dir for additional .ini files	/usr/local/php56/etc
Additional .ini files parsed	/usr/local/php56/etc/extensions.ini, /usr/local/php56/etc/limits.ini
PHP API	20131106
PHP Extension	20131226
Zend Extension	220131226
Zend Extension Build	API220131226,NTS
PHP Extension Build	API20131226,NTS
Debug Build	no
Thread Safety	disabled
Zend Signal Handling	disabled
Zend Memory Manager	enabled
Zend Multibyte Support	provided by mbstring
IPv6 Support	disabled
DTrace Support	disabled
Registered PHP Streams	https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports	tcp, udp, unix, udg, ssl, sslv3, sslv2, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters	zlib.*, bzip2.*, convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk

**live (not working):** 

    PHP Version 5.4.19

    System	Linux p3nlhg1348.shr.prod.phx3.secureserver.net 2.6.32-604.30.3.lve1.3.63.el6.nfsfixes.x86_64 #1 SMP Mon Oct 26 11:56:49 MST 2015 x86_64
    Build Date	Sep 4 2013 12:07:19
    Configure Command	'./configure' '--with-libdir=lib' '--enable-fastcgi' '--prefix=/usr/local/php5_4' '--with-config-file-path=/web/conf' '--disable-posix' '--enable-bcmath' '--enable-calendar' '--with-curl=/usr/bin/curl' '--with-gdbm' '--enable-exif' '--enable-ftp' '--with-gd' '--with-freetype-dir=/usr' '--with-jpeg-dir=/usr' '--with-png-dir=/usr/bin/libpng-config' '--enable-gd-native-ttf' '--with-gettext' '--with-mcrypt=/usr/bin/libmcrypt-config' '--with-mhash' '--with-pdo' '--with-pdo-mysql=/usr' '--with-mysql=/usr' '--with-mysqli=/usr/bin/mysql_config' '--with-openssl' '--with-pspell' '--enable-soap' '--enable-wddx' '--with-xsl' '--with-zlib' '--enable-mbstring' '--enable-zip' '--with-xmlrpc' '--sysconfdir=/web/httpd24/conf' '--enable-apc'
    Server API	CGI/FastCGI
    Virtual Directory Support	disabled
    Configuration File (php.ini) Path	/web/conf
    Loaded Configuration File	/web/conf/php5.ini
    Scan this dir for additional .ini files	(none)
    Additional .ini files parsed	(none)
    PHP API	20100412
    PHP Extension	20100525
    Zend Extension	220100525
    Zend Extension Build	API220100525,NTS
    PHP Extension Build	API20100525,NTS
    Debug Build	no
    Thread Safety	disabled
    Zend Signal Handling	disabled
    Zend Memory Manager	enabled
    Zend Multibyte Support	provided by mbstring
    IPv6 Support	enabled
    DTrace Support	disabled
    Registered PHP Streams	https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar, zip
    Registered Stream Socket Transports	tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
    Registered Stream Filters	zlib.*, convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk




Any ideas about what’s going on?

I can always change it to a regular text field and create a regex validator to make sure the it stays in the proper format - but the client isn’t super web-savvy and I’d prefer to leave the date picker in if possible.

The loading time when saving the pre-1900 date is very long, so it seems like there is some kind of loop happening on the backend that shouldn’t be happening. Also, the reason for the reverted date is that the field is marked as invalid, which is even more strange.

Could you please check your error log and inspect the XHR (AJAX) request and response the Panel sends to the server using your browser’s web inspector?

I’m not sure why it took a while when I made that GIF, but the loading happens almost immediately. Here’s another one - also showing another strange thing I noticed, the date 1970-01-01 also doesn’t work.

Here is a .HAR file from the XHR request. I didn’t see anything in it - but wasn’t sure where to look. PHP Error logs on the server show nothing.

The date validator, strtotime('1970-01-01') returns 0, so this will in fact not validate. I consider this a bug. As for timestamps prior to that date, they return a negative UNIX timestamp, but I don’t see why this should not be supported on the live server.

You’re right, the culprit is simply strtotime(), and nothing to do with Kirby.

strtotime("1900-01-01") returns false on the live server, and -2208992400 on the beta server. It looks like this is a problem with 32-bit architecture:

But, it looks like the live server is actually 64-bit. From phpInfo():

  System
  Linux p3nlhg1347.shr.prod.phx3.secureserver.net 2.6.32-604.30.3.lve1.3.63.el6.nfsfixes.x86_64 #1 SMP Mon Oct 26 11:56:49 MST 2015 x86_64

No clue what’s going on, but, I’ll investigate and report back.

One more reason to avoid GoDaddy!

Yes, exactly, the 32-bit issue was on my mind as well, but as the server does not seem to be 32-bit, it’s weird.

Edit: I created an issue on Github re. the “1970-01-01” bug.

1 Like

I have created a fix for the 1970-01-01 bug that will hopefully be part of the next release.

Theoretically, PHP could be compiled as a 32-bit version, but who would do that? :smiley:
Really strange…

The “1970-01-01” bug is now fixed on the development branch.

I suddenly have this problem with a live version (2.5.12, php 7.2) What can i do?