• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.