note 78877 added to function.strtotime

From: Date: Wed, 31 Oct 2007 13:33:56 +0000
Subject: note 78877 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-131864@lists.php.net to get a copy of this message
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. ---- Server IP: 208.69.120.35 Probable Submitter: 69.252.196.53 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/78877 Del: integrated -- https://master.php.net/note/delete/78877/integrated Del: useless -- https://master.php.net/note/delete/78877/useless Del: bad code -- https://master.php.net/note/delete/78877/bad+code Del: spam -- https://master.php.net/note/delete/78877/spam Del: non-english -- https://master.php.net/note/delete/78877/non-english Del: in docs -- https://master.php.net/note/delete/78877/in+docs Del: other reasons-- https://master.php.net/note/delete/78877 Reject -- https://master.php.net/note/reject/78877 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131864) next »