how to get current date in codeigniter? – Date Helper Example

how to get current date in codeigniter? – To get current date time you have to use the function mdate() in codeigniter. It is best simple way to get the current time & date in PHP codeigniter Examples.

current date in codeigniter – how to get current date in codeigniter?

How to Get Current Date Time in CodeIgniter using Date Helper Example with demo.

<?php echo @date('Y-m-d H:i:s'); ?>

Load Date Helper

$this->load->helper('date');

current date in codeigniter

date('Y-m-d');

CodeIgniter: Get Current Date Time

$format = "%Y-%m-%d %h:%i %A";
echo mdate($format);

// output:
2022-09-10 03:11 PM

get the date time in 24 hours format.

$format = "%Y-%M-%d %H:%i";
echo mdate($format);

// output:
// 2022-Oct-01 15:11

How to Get Current Date Time in CodeIgniter?

And this is the controller simple demo with function to print the current or active date time in codeigniter.

<?php
class getPerson extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->helper('url');
    }
    
    function index()
    {
        $this->getDateTime();
    }
    
    function getDateTime()
    {
        //load date helper
        $this->load->helper('date');

        $join_dt = "%Y-%m-%d %h:%i %a";
        echo @mdate($join_dt);
    }
}
?>

date between query in codeigniter

How to check current date between two dates in codeigniter?

$this->db->where('sell_date BETWEEN "'. date('Y-m-d', strtotime($join_dt)). '" and "'. date('Y-m-d', strtotime($last_dt)).'"');

Codeigniter Date Time Demo

<!--?php
defined('BASEPATH') OR exit('No direct script access allowed');

class JoinDt extends CI_Controller {
	function getCurrentDate(){

		$this--->load->helper('date');

		$format = "%Y-%m-%d %h:%i %A";
		echo mdate($format);

	}

}
?>

Codeigniter where date greater than today

also you can check here to using =< to <= 'Greater than or equal' and 'less than or equal' CODEIGNITER

Read Also:  custom search form wordpress - How to Create Custom Search Form in WordPress?
->where('student.joindate >=', $month_start)
->where('student.joindate <=', $month_end)
$this->db->where('joindate >', 'DATE_SUB(NOW(), INTERVAL 1 DAY)');

I hope you get an idea about how to get current date in codeigniter?.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.