Home › Forums › Front-end Issues › Manipulating datepicker data › Reply To: Manipulating datepicker data
Elliot
Ok have found a bit of time to try and get my head round extracting elements of the date picker value.
However this code
<?php
$date = get_field('course_date');
// $date = 19881123 (23/11/1988)
// extract Y,M,D
$y = substr($date, 0, 4);
$m = substr($date, 4, 2);
$d = substr($date, 6, 2);
// create UNIX
$time = strtotime("{$d}-{$m}-{$y}");
// format date (23/11/1988)
?>
<div class="calendar">
<p class="calendarDate"><span class="dow"><?php echo date('D' ); ?></span>
<span class="day"><?php echo date('d'); ?> <br /><?php echo date('M'); ?></span>
<span class="year"><?php echo date('Y'); ?></span>
</p>
</div>
Outputs today’s date and not the date entered via Date Picker whose Field name is course_date.
If I used the code on http://www.advancedcustomfields.com/resources/field-types/date-picker/ I get the 1st Jan 1970 outputted.
A steer in the right direction would be a lifesaver. php version is 5.2.17
Website: http://tideswellschooloffood.co.uk
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.