note 100116 deleted from function.mktime by aharvey

From: Date: Fri, 07 Sep 2012 01:16:42 +0000
Subject: note 100116 deleted from function.mktime by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190561@lists.php.net to get a copy of this message
Note Submitter: enVide neFelibata ---- I've had this query for an event organizer. <?php $query = "SELECT MAX(dt_atfrom) FROM tb_date LIMIT 1"; $raw_data = mysql_query($query); $maxdate = mysql_result($raw_data,0,0); ?> It would fetch the 'bigger' date of all of those events. The problem started when having events in the future. I'll start to explain. Imagine you're in '2010' and the biggest event date is '2011-06-05'. $maxdate will return me the correct data '2011-06-05', yet since I was only needing the year i passed this date through the following function: <?php maxyear = date("Y", mktime($maxdate)); ?> mktime was returning me the actual year for every future event instead of the future year. I ended up doing the following: <?php $maxyear = substr($maxdate,0,4); ?> Probably there's a better solution...

« previous php.notes (#190561) next »