note 100525 added to function.strtotime

From: Date: Thu, 21 Oct 2010 12:38:58 +0000
Subject: note 100525 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-173338@lists.php.net to get a copy of this message
A much better way to work out the days left in the month: // Gets the number of days left in the month. ISO 2014 format date in, int out. function getDaysLeftInMonth($date = null, $includingToday = true) { if ($date == null) { $date = date('Y-m-d'); } $currentTime = strtotime($date); $futureTime = strtotime(date('Y-m-01', strtotime("{$date} + 1 month"))); $daysLeft = round(($futureTime - $currentTime) / 86400); // 60 seconds * 60 minutes * 24 hours = 86400 seconds in a day if ($includingToday == true) { return $daysLeft; } else { return $daysLeft - 1; } } ---- Server IP: 69.147.83.197 Probable Submitter: 82.69.105.163 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/100525 Del: integrated -- https://master.php.net/note/delete/100525/integrated Del: useless -- https://master.php.net/note/delete/100525/useless Del: bad code -- https://master.php.net/note/delete/100525/bad+code Del: spam -- https://master.php.net/note/delete/100525/spam Del: non-english -- https://master.php.net/note/delete/100525/non-english Del: in docs -- https://master.php.net/note/delete/100525/in+docs Del: other reasons-- https://master.php.net/note/delete/100525 Reject -- https://master.php.net/note/reject/100525 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173338) next »