Skip to content

Instantly share code, notes, and snippets.

@infoscigeek
Last active October 31, 2016 13:06
Show Gist options
  • Save infoscigeek/8f1ad5ede827c3624e4f48df1b0eca3c to your computer and use it in GitHub Desktop.
Save infoscigeek/8f1ad5ede827c3624e4f48df1b0eca3c to your computer and use it in GitHub Desktop.
Reformatting poorly inputted data and displaying it properly. (In this case, minute and hour fields were stored separately)
<?
//assign variables
$start_hour_field = get_field_object('start_hour');
$starthour = $start_hour_field['value'];
$start_min_field = get_field_object('start_min');
$startmin = $start_min_field['value'];
$end_hour_field = get_field_object('end_hour');
$endhour = $end_hour_field['value'];
$end_min_field = get_field_object('end_min');
$endmin = $end_min_field['value'];
?>
<td>
<?
//display as 08:15 A.M.
if ($starthour>=12)
{
echo $starthour - 12;
}
else {
echo $starthour;
}
?>
:
<?php echo $startmin; ?>
<?if ($starthour>=12)
{
echo " P.M.";
}
else {
echo " A.M.";
}
?>
</td>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment