Support

Account

Home Forums General Issues Empty date field return 'null' and '' (empty string)

Solved

Empty date field return 'null' and '' (empty string)

  • If I get_field('my-date-field), the not filled date fields return NULL. But, if I fill the field with a date and, then, remove the date leave it empty again, it return an empty string.

    Why? Is it posiible to return the same in both cases?

    Thank you.

  • Solved. I was creating datetime from empty field:

    new \DateTime(get_field('date', $item->ID, false))

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Empty date field return 'null' and '' (empty string)’ is closed to new replies.