note 100263 deleted from function.mktime by danbrown

From: Date: Tue, 05 Oct 2010 05:00:38 +0000
Subject: note 100263 deleted from function.mktime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172961@lists.php.net to get a copy of this message
Note Submitter: olev at araamat dot org ---- The example by 'contact at phpmember dot com' doesn't work as expected. <?php # the author used $days = floor((time()-mktime(null,null,null,1,0,date("Y")))/86400); # but presumably wanted to achieve smth like $days = floor((time()-mktime(date('H'),date('i'),date('s'),1,1))/86400); ?> 1) Using 'null' as an argument in mktime() doesn't have the effect of omitting an argument. It becomes 0, not the current value. The manual says 'Arguments may be left out in order from right to left; any arguments thus omitted will be set to the current value according to the local date and time.' 2) Setting days to 0 means the last day of the previous month. Thus the example gives wrong results (adds 1 day). 3) The last argument is unnecessary, omitting it would also set the year to the current value.

« previous php.notes (#172961) next »