Created
February 15, 2020 13:26
-
-
Save shawn-crigger/cc925a123154b1f08334a1f29681aa01 to your computer and use it in GitHub Desktop.
This class can calculate the percentage of the days that passed.
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 | |
/* | |
*I dont know if this can be useful for you but | |
* | |
*I came up with it, and I give it as a present to you. | |
* | |
*I'm not a skillful programmer, I just enjoy doing this, | |
* | |
*Thanks for reading | |
********************************************************* | |
*No se si realmente esto te ser? util pero | |
* | |
*Se me ocurri? y te lo estoy regalando | |
* | |
*No soy un avanzado programador, solo disfruto haciendo | |
* | |
*Estas peque?as cosas | |
* | |
*Gracias por leer | |
*/ | |
class datePercent | |
{ | |
public function percDays() | |
{ | |
$daysofmonth=cal_days_in_month(CAL_GREGORIAN,date('j'),date('Y')); //Obtaining if this month has 28, 30 or 31 days | |
$today=date('d'); | |
$perc= round ($today / $daysofmonth * 100, PHP_ROUND_HALF_DOWN); //rounding the result | |
return $perc ; | |
} | |
public function percMonth() | |
{ | |
$today=date('d'); | |
$perc= round ($today / 365 * 100, PHP_ROUND_HALF_DOWN); //rounding the result | |
return $perc; | |
} | |
} | |
$obj= new datepercent; | |
echo '<pre>'; | |
echo 'This month is to the '.$obj->percDays().' percent'; | |
echo '<br>'; | |
echo 'This year is to the '.$obj->percMonth().' percent'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment