Created
June 29, 2016 14:53
-
-
Save pixel5/5760e31bcd67bba6f885bfc53056701e to your computer and use it in GitHub Desktop.
ridiculous date string comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Make sales chart data | |
$i = 1; | |
foreach ($master['eom'] as $key => $eom) { | |
$key_compare = intval(substr($key, -2)); | |
$starting_index_month = intval(substr($EOM_STARTING_INDEX + ($i - 1), -2)); | |
$month_compare = $starting_index_month <= 12 ? $starting_index_month : $starting_index_month - 12; | |
$diff = $key_compare - $month_compare; | |
$i = $i + $diff; | |
$m = date('M y', strtotime($eom->datetime)); | |
$labels[$i] = $m; | |
// Append to data arrays | |
$data_sold[$i] = intval($eom->sold_units); | |
$data_returned[$i] = intval(abs($eom->returned_units)); | |
$data_netunits[$i] = $data_sold[$i] - $data_returned[$i]; | |
$i++; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment