Created
January 3, 2017 03:31
-
-
Save moeseth/66602f8b69bb6f6fce56ca82e8fdae34 to your computer and use it in GitHub Desktop.
A php function to calculate pawn months in Myanmar
This file contains hidden or 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 | |
function calculate_pawn_months($start_date, $end_date) | |
{ | |
$start_date = new DateTime($start_date); | |
$end_date = new DateTime($end_date); | |
$diff_months = ($start_date->diff($end_date)->m + ($start_date->diff($end_date)->y * 12)); | |
$total_days = $start_date->diff($end_date)->d; | |
if ($diff_months > 0) { | |
if ($total_days > 0) { | |
if ($total_days <= 15) { | |
$diff_months += 0.5; | |
} else { | |
$diff_months += 1; | |
} | |
} | |
} else { | |
$diff_months = 1; | |
} | |
return $diff_months; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment