PHP – Get Last 12 Months

<?php
$to = new DateTime('now');
$from = new DateTime('now');
$from->modify("-12 months");
$interval = DateInterval::createFromDateString('1 month');
$period   = new DatePeriod($from, $interval, $to);
$res = array();

foreach ($period as $start)
{
  $res[] = $start->format('m/Y');
}

echo "<pre>";
var_dump($res);
echo "</pre>";

/**
--- Output --- 
array(12) {
  [0]=>
  string(7) "02/2019"
  [1]=>
  string(7) "03/2019"
  [2]=>
  string(7) "04/2019"
  [3]=>
  string(7) "05/2019"
  [4]=>
  string(7) "06/2019"
  [5]=>
  string(7) "07/2019"
  [6]=>
  string(7) "08/2019"
  [7]=>
  string(7) "09/2019"
  [8]=>
  string(7) "10/2019"
  [9]=>
  string(7) "11/2019"
  [10]=>
  string(7) "12/2019"
  [11]=>
  string(7) "01/2020"
}
*/

Social Poster – A Simple Facebook Page and Twitter poster

Social (Media) Poster

Social Poster is a simple Facebook Page and Twitt poster

  • Text Posting
  • Text with Image-\s Posting

Tech

Social Poster uses a number of open source projects to work properly:

  • facebook/graph-sdk – Facebook SDK for PHP (v5)
  • dg/twitter-php – Twitter for PHP is a very small and easy-to-use library for sending messages to Twitter and receiving status updates.
  • dillinger.io – Markdown editor for this readme.md creating/editing. Fast and easy to extend.
  • Twitter Bootstrap – great UI boilerplate for modern web apps
  • jQuery – duh

Integration

Facebook

  • Create Facebook Developer Account
  • Create Simple App
    • You not need Facebook Products other anything under Your App Settings, I have only Contact E-mail filled
    • Call https://developers.facebook.com/tools/explorer/
    • Select Your App under Application Select
    • Select Page Access Token under Get Token Button
    • Click i icon after Access Token Creating
    • Click Open in Access Token Tool from opened Internal Popup
    • Click Generate Long Lived Token

Twitter

  • Create Twitter Developer Account
  • Create Simple App
    • Click App Details
    • This Keys will be located under Keys and tokens Menu