Welcome Guest, Not a member yet? Register   Sign In
Date
#1

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

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

If you have a CI4 Time object you can simple use the getters (https://codeigniter4.github.io/CodeIgnit...ml#getters):

$time->day
$time->month
Reply




Theme © iAndrew 2016 - Forum software by © MyBB