note 116989 added to function.cal-days-in-month
| From: | XombyCraft at gmail dot com | Date: | Tue, 31 Mar 2015 00:10:26 +0000 |
| Subject: | note 116989 added to function.cal-days-in-month | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202090@lists.php.net to get a copy of this message | ||
To get the number of days in a given month, you just need to pass a timestamp that occurs during
that month to the date function.
I've found this is beneficial when I cannot guarantee a particular set of functionality has
been compiled into a given PHP installation.
<?php
$month = "2"
$year = "2014"
date("t",mktime(0,0,0,$month,1,$year));
//equivalent to
date("t",mktime(0,0,0,2,1,2014));
//returns 28
?>
----
Server IP: 72.52.91.14
Probable Submitter: 70.105.165.148
----
Manual Page -- http://php.net/manual/en/function.cal-days-in-month.php
Edit -- https://master.php.net/note/edit/116989
Del: integrated -- https://master.php.net/note/delete/116989/integrated
Del: useless -- https://master.php.net/note/delete/116989/useless
Del: bad code -- https://master.php.net/note/delete/116989/bad+code
Del: spam -- https://master.php.net/note/delete/116989/spam
Del: non-english -- https://master.php.net/note/delete/116989/non-english
Del: in docs -- https://master.php.net/note/delete/116989/in+docs
Del: other reasons-- https://master.php.net/note/delete/116989
Reject -- https://master.php.net/note/reject/116989
Search -- https://master.php.net/manage/user-notes.php