note 101294 deleted from function.date by tularis
| From: | tularis@php.net | Date: | Thu, 09 Feb 2012 20:52:34 +0000 |
| Subject: | note 101294 deleted from function.date by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185964@lists.php.net to get a copy of this message | ||
Note Submitter: iphraimov at gmail dot com
----
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;
}
?>