Skip to content

Instantly share code, notes, and snippets.

@dillinghamio
Last active February 17, 2017 19:52
Show Gist options
  • Save dillinghamio/692b847ebd281e4a1c6c7ec9ec3b986d to your computer and use it in GitHub Desktop.
Save dillinghamio/692b847ebd281e4a1c6c7ec9ec3b986d to your computer and use it in GitHub Desktop.
$originalStartDate = app('Carbon\Carbon')->parse('1/30/2017');
$newStartDate = app('Carbon\Carbon')->parse('2/27/2017');
$difference = $originalStartDate->diffInDays($newStartDate);
$dates = [
'2/20/2017',
'2/24/2017',
'3/6/2017',
'3/27/2017',
'4/3/2017',
'4/10/2017',
];
foreach($dates as $key => $date)
{
$dates[$key]['original'] = app('Carbon\Carbon')->parse($date);
$dates[$key]['new'] = app('Carbon\Carbon')->parse($date)->addDays($difference);
}
foreach($dates as $key => $date)
{
echo "original: " . $date['original']->format('l m/d/Y') . "<br>";
echo "new: " . $date['new']->format('l m/d/Y') . "<br>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment