Error when saving Custom Field dates < 1970

Using RT6.0, after upgrade from RT5.0.1- have custom fields which contain dates. These will not now save dates < 1970 - so looks like a UNIX date format issue. Can see in apache error log

“[55422] [Mon Dec 22 17:09:03 2025] [notice]: Passed a unix time less than 0, forcing to 0: [-148608000] (/opt/rt6/sbin/../lib/RT/Date.pm:888)“

Have been through Date.PM and RT Config, cannot find anything obvious.

Anyone have any ideas?

Thanks, Colm

I don’t believe you can set a date field before the epoch using a date/datetime custom field

The actual values for data entered into custom fields is stored as a string in ObjectCustomFieldValues. when using either date or date time, the TempusDominus date picker control or manual date entry will return a date. In RT V5, this data was simply stored in the table. In V6, it looks as if the value is treated as a Unix EPOCH date, and for dates < 1970, that number becomes negative and throws the error. Really the code should just check if the date string entered is a valid date and store it regardless. Not a lot of point in having an ability for a custom date field if it is limited to a range of +/- 68 years from 1970

I just faced the same issue: I’m using a CustomField for birthdate and just had to deal with someone born in 1966 :slight_smile:

Here’s a quick dirty hack to fix it for CustomFields:

Add this to your RT_SiteConfig.pm

Set($PreferDateTimeFormatNatural, 1);

In Date.pm:

In ParseByDateTimeFormatNatural(), store $dt in $self if $date < 0:

    if ($date < 0) {
            $self->{DateTimeObj} = $dt;
    }

In ISO(), add this to override the values returned by Localtime:

if (exists $self->{DateTimeObj}) {
    $year = $self->{DateTimeObj}->year;
    $mon = $self->{DateTimeObj}->month;
    $mday = $self->{DateTimeObj}->day;
    $hour = $self->{DateTimeObj}->hour;
    $min = $self->{DateTimeObj}->minute;
    $sec = $self->{DateTimeObj}->second;
}

And finally in IsSet():

return 1 if (exists $self->{DateTimeObj});

return $self->Unix ? 1 : 0;

But yeah the whole Unix() thing in Date must go away…