note 100116 added to function.mktime
| From: | enVideneFelibata at osu1 dot php dot net | Date: | Sun, 26 Sep 2010 13:34:46 +0000 |
| Subject: | note 100116 added to function.mktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172726@lists.php.net to get a copy of this message | ||
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...
----
Server IP: 194.8.30.16
Probable Submitter: 188.80.51.68
----
Manual Page -- http://www.php.net/manual/en/function.mktime.php
Edit -- https://master.php.net/note/edit/100116
Del: integrated -- https://master.php.net/note/delete/100116/integrated
Del: useless -- https://master.php.net/note/delete/100116/useless
Del: bad code -- https://master.php.net/note/delete/100116/bad+code
Del: spam -- https://master.php.net/note/delete/100116/spam
Del: non-english -- https://master.php.net/note/delete/100116/non-english
Del: in docs -- https://master.php.net/note/delete/100116/in+docs
Del: other reasons-- https://master.php.net/note/delete/100116
Reject -- https://master.php.net/note/reject/100116
Search -- https://master.php.net/manage/user-notes.php