What is the logic behind defaulting to REQUEST_TIME for empty date fields?

if ($type == 'date') {
    $date = !empty($data['date']) ? $data['date'] : REQUEST_TIME;

I have an optional deadline field for which i use a token to display the date. If the deadline isn't set, i don't want the current date to be displayed. I just want it to be empty (or not be replaced so i can remove it after).

As it is now, there is no way to distinguish between an empty field and a filled one.

Comments

jeastham’s picture

This becomes a real problem when exporting fields in modules like Fill PDF. If date fields are left blank, the token returns the current date, making it difficult to have optional date fields.

Dave Reid’s picture

Status: Active » Closed (duplicate)

This is because we have to match the core behavior. See the system_tokens() function in core. Unfortunately since this bug was not able to be fixed prior to 7.0 release, I don't think we can fix it until Drupal 8 with #943028: 'Date' token namespace is ambiguous