CodeIgniter Forums
Date - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forum-31.html)
+--- Thread: Date (/thread-77205.html)



Date - swangchu - 08-01-2020

How can I extract day and month from date in Codeigniter 4?


RE: Date - InsiteFX - 08-02-2020

Quick example:

PHP Code:
$timestamp time();

$date date('Y-m-d'$timestamp);
        
$fields explode('-'$date);

echo 
'Year  = '.$fields[0]."<br>";
echo 
'Month = '.$fields[1]."<br>";
echo 
'Day   = '.$fields[2]; 

Or you can use the PHP DateTime object.