I am using Advanced Custom fields in wordpress to input the start and end date of a particular tour. That date is formated mmddyy (10052013).
I'm trying to use PHP to format the date. The code is as follows:
<?php
$date = get_field('start_date');
$y = substr($date, 4, 4); $m = substr($date, 0, 2); $d = substr($date, 2, 2);
// create UNIX
$time = strtotime("{$d}-{$m}-{$y}");
// format date (November 11th 1988)
echo date('F n, Y', $time);
?>
<?php
if(get_field('end_date')){
$date = get_field('end_date');
$y = substr($date, 4, 4); $m = substr($date, 0, 2); $d = substr($date, 2, 2);
// create UNIX
$time = strtotime("{$d}-{$m}-{$y}");
// format date (November 11th 1988)
echo ' - ' . date('F n, Y', $time);
}
?>
But when the dates are rendered on the page, for some reason, the date is always "October 10, 2013" and I don't know why. You can see it in action here: http://onedirectionconnection.com/tester/?projects=take-me-home-tour
I output the database values as they're saved normally to show that they're definitely saved correctly. It's something going wrong in the way I coded the PHP.
Could anyone help me out here?