php last 12 month

 avatar
unknown
php
4 years ago
517 B
4
Indexable
    public function last_mounth()
    {
        setlocale(LC_TIME, 'tr_TR.UTF-8');
        $latest_mounth = [];
        for ($i=0; $i <= 12 ; $i++) {
            $latest_mounth[$i] = new \stdClass;
            $latest_mounth[$i]->date = date("Y-m-d",strtotime("-".$i." months"));
            $latest_mounth[$i]->id = $i;
            $latest_mounth[$i]->text = strftime('%m %B',strtotime("-".$i." months"));
        }
        return Response::withData(true, 'last 12 mounth successfully listed', $latest_mounth);
    }
Editor is loading...