php echo last month code example

Example 1: get last character of string php

substr("testers", -1); // returns "s"

Example 2: get last month php

$currentMonth = date('M');// if number, then date('m');
//Last month
$lastMonth = Date("F", strtotime("first day of previous month");
$nextMonth = Date("F", strtotime("first day of next month");

Example 3: +1 month php

$time = strtotime("2010.12.11");
$final = date("Y-m-d", strtotime("+1 month", $time));

Example 4: get last month using php

//Last month
$lastMonth = Date("F", strtotime("first day of previous month");
$nextMonth = Date("F", strtotime("first day of next month");

Tags:

Php Example