note 78877 rejected from function.strtotime by nlopess

From: Date: Wed, 31 Oct 2007 21:21:40 +0000
Subject: note 78877 rejected from function.strtotime by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-131878@lists.php.net to get a copy of this message
Note Submitter: brandon at brandonobrien dot com ---- Does anyone know of an easier solution to fixing the strtotime("-1 month") issue than what I have done below? <? $thisMonth = date("n"); $thisYear = date("Y"); $lastMonth = $thisMonth-1; if($lastMonth < 1) { $lastMonth = 12; $thisYear--; } $lastMonthFull = date("Y-m-d",strtotime("$thisYear-$lastMonth-01")); ?> It's very frustrating having to do all of that code simply to find the last month. For whatever reason "-1 month" simply subtracts 30 days, not one month.

« previous php.notes (#131878) next »