...
Code Block | ||
---|---|---|
| ||
// ✅ Set the date using separate date/time virtural fields:
$object->SetDBField('FieldName_date', 1721215210);
$object->SetDBField('FieldName_time', 1721215210);
$object->Update(); // The 'FieldName' field now has combined value of _date/_time fields.
// ✅ Set the date using the database field/_combined virtual field:
$object->SetDBField('FieldName', 1721215210);
$object->SetDBField('FieldName_combined', 1);
$object->Update(); // The _date/_time fields aren't used.
// ❌ Set the date using the database field only:
$object->SetDBField('FieldName', 1721215210);
$object->UpdateFormattersSubFields(array('FieldName'));
$object->Update(); // The _date/_time fields are set from the 'FieldName' field.
// ✅ Sets the credit card expiration using CreditCardExpirationMonth/CreditCardExpirationYear virtual fields.
$object->SetDBField('CreditCardExpirationMonth', '05');
$object->SetDBField('CreditCardExpirationYear', '24');
$object->Update(); // The 'CreditCardExpiration' field now has combined value of the above set fields.
// ❌ Sets the credit card expiration using the database field only.
$object->SetDBField('CreditCardExpiration', '05/24');
$object->UpdateFormattersSubFields(array('CreditCardExpiration'));
$object->Update(); // The _month/_year fields are set from the 'CreditCardExpiration' field. |
All solutions work when setting a non-empty value. However, the solutions marked with the ❌ sign don’t allow for clearing the field's existing value.
...
Update the “\kDateFormatter::UpdateSubFields” and “\kCCDateFormatter::UpdateSubFields” methods method to support empty values.
Related Tasks
...