date - Can't convert ACF datepicker value to DateTime oject - gives me a boolean

I keep getting this error Call to a member function modify() on boolean with this code $date_value = the_sub_field( 

I keep getting this error Call to a member function modify() on boolean with this code

$date_value = the_sub_field( 'date_string' );
$date = DateTime::createFromFormat('d/m/Y', $date_value);
$date->modify('+1 day');  

The last line gives me an error. Both of my formats (display and return inside of ACF) are the same 'd/m/Y'

Really frustrating stuff!

I keep getting this error Call to a member function modify() on boolean with this code

$date_value = the_sub_field( 'date_string' );
$date = DateTime::createFromFormat('d/m/Y', $date_value);
$date->modify('+1 day');  

The last line gives me an error. Both of my formats (display and return inside of ACF) are the same 'd/m/Y'

Really frustrating stuff!

Share Improve this question asked Oct 14, 2019 at 16:51 ivan marchenkoivan marchenko 1491 silver badge6 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

the_sub_field() echoes out the sub field. Use get_sub_field() instead.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745082181a4610195.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信