Today, Yesterday, First Date Of Month and Year
Load the date Helper First
Open ...application/config/autoload.php file and edit this file
$autoload['helper'] = array('url','form','html','date');
/*** Here I have edit the date ****/
Or
You Can Load this manually:
This helper is loaded using the following code :
$this -> load -> helper ('date');
After Loading write the code in a view and load this view within a controller and run it
$time = time();
$todayformat = "%Y-%m-%d";
$todaydate = mdate($todayformat, $time);
echo $todaydate; ?>
$yesterday = time()-(60*60*24);
$yesterdaydate = date("Y-m-d", mktime(0, 0, 0,date("m",$yesterday),date("d",$yesterday),date("Y",$yesterday)));
echo $yesterdaydate; ?>
$firstday = "%Y-%m-1";
$firstdaydate = mdate($firstday, $time);
echo $firstdaydate; ?>
$first = "%Y-1-1";
$first = mdate($first, $time);
echo $first; ?>
?>
Comments
Post a Comment