note 101294 added to function.date
| From: | iphraimov at gmail dot com | Date: | Wed, 08 Dec 2010 16:15:53 +0000 |
| Subject: | note 101294 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174711@lists.php.net to get a copy of this message | ||
Here is simple function to generate date selection, useful for admin panels ....
<?php
public static function dateRange($fmt = 'j-n-Y', $sep='+') {
$current_time = time();
$year = date('Y',$curr_time);
$month = date('n',$curr_time);
$day = date('j',$curr_time);
$today = date($fmt, $curr_time);
$r = array (
'all' => $sep.$sep.$sep,
'today' => $today.$sep.$today,
'yesterday' => date($fmt, strtotime('-1 day',$curr_time)).$sep.date($fmt,
strtotime('-1 day',$curr_time)),
'last7days' => date($fmt, strtotime('-7 day',$curr_time)).$sep.$today,
'thismonth' => date($fmt, mktime(0,0,0,$month, 1, $year)).$sep.$today,
'thisyear' => date($fmt, mktime(0,0,0,1, 1, $year) ).$sep.$today,
);
return $r;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 79.183.196.172
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/101294
Del: integrated -- https://master.php.net/note/delete/101294/integrated
Del: useless -- https://master.php.net/note/delete/101294/useless
Del: bad code -- https://master.php.net/note/delete/101294/bad+code
Del: spam -- https://master.php.net/note/delete/101294/spam
Del: non-english -- https://master.php.net/note/delete/101294/non-english
Del: in docs -- https://master.php.net/note/delete/101294/in+docs
Del: other reasons-- https://master.php.net/note/delete/101294
Reject -- https://master.php.net/note/reject/101294
Search -- https://master.php.net/manage/user-notes.php