Skip to content

Instantly share code, notes, and snippets.

@shawn-crigger
Created February 15, 2020 13:26
Show Gist options
  • Select an option

  • Save shawn-crigger/cc925a123154b1f08334a1f29681aa01 to your computer and use it in GitHub Desktop.

Select an option

Save shawn-crigger/cc925a123154b1f08334a1f29681aa01 to your computer and use it in GitHub Desktop.

Revisions

  1. shawn-crigger created this gist Feb 15, 2020.
    43 changes: 43 additions & 0 deletions date-percentage.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    <?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';