Home › Forums › ACF PRO › Get date or time from the Date & Time Picker field › Reply To: Get date or time from the Date & Time Picker field
The best way to get only the date or the time is by converting the value to a date object like this:
$date = get_field('date_time_picker', 85, false); $date = DateTime::createFromFormat('Y-m-d H:i:s', $date); echo $date->format('Y-m-d'); echo "\n"; echo $date->format('H:i:s');
Please check this page to see the available format: http://php.net/manual/en/function.date.php.
I’m afraid you need to query it as whole date and time. If you need to query it separately, you need to create separate fields for the date and the time.
I hope this makes sense 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!