Array
(
    [0] => Warning
    [1] => Undefined array key "language"
    [2] => /home/whmcsdev/public_repo/wbteampro.major-release/installation/modules/addons/wbteampro/initialize.php
    [3] => 282
)
Array
(
    [0] => Warning
    [1] => Undefined property: stdClass::$state
    [2] => /home/whmcsdev/public_repo/wbavatax.master/installation/modules/addons/wbavatax/hooks.php
    [3] => 942
)
Array
(
    [0] => Deprecated
    [1] => htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated
    [2] => /home/whmcsdev/public_repo/wbavatax.master/installation/modules/addons/wbavatax/hooks.php
    [3] => 279
)
PHP Finding First and Last day of a month - Knowledgebase - WHMCS Dev
Dev License: This installation of WHMCS is running under a Development License and is not authorized to be used for production use. Please report any cases of abuse to abuse@whmcs.com

PHP Finding First and Last day of a month Print

  • 3

Oh how much we love the ever-so-useful strtotime() function, which acts like the workhorse in so many calendar based operations.  With strtotime() you can create a date for an SQL query in a snap.

$lastMonth_start  = date('Y-m-01', strtotime('last month'));
$lastMonth_stop   = date('Y-m-d', strtotime(date('Y-m-01', strtotime('this month')).' -1 minute'));
echo $lastMonth_start.' '.$lastMonth_stop.'<br>';

$thisMonth_start  = date('Y-m-01', strtotime('this month'));
$thisMonth_stop   = date('Y-m-d', strtotime(date('Y-m-01', strtotime('next month')).' -1 minute'));
echo $thisMonth_start.' '.$thisMonth_stop.'<br>';

$nextMonth_start  = date('Y-m-01', strtotime('next month'));
$nextMonth_stop   = date('Y-m-d', strtotime(date('Y-m-01', strtotime('this month +2 months')).' -1 minute'));
echo $nextMonth_start.' '.$nextMonth_stop.'<br>';



Was this answer helpful?

« Back

Powered by WHMCompleteSolution