Support

Account

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