Created
January 31, 2020 18:59
-
-
Save franciscopessoa/fabf8e031185f10a7ab300ba40836752 to your computer and use it in GitHub Desktop.
Calcular mês comercial, 26 a 25
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 | |
function dataCompetencia($data) | |
{ | |
$dia = (int) substr($data, 8, 2); | |
$AnoMes = substr($data, 0, 7); | |
if ($dia >= 26) { | |
$date['inicial'] = $AnoMes . '-26'; | |
$date['final'] = date('Y-m', strtotime('+ 1 Month', strtotime($AnoMes))) . '-25'; | |
} else { | |
$date['inicial'] = date('Y-m', strtotime('- 1 Month', strtotime($AnoMes))) . '-26'; | |
$date['final'] = $AnoMes . '-25'; | |
} | |
return $date; | |
} | |
print_r(dataCompetencia(date('Y-m-d'))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment