⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Separate date when datetime field



beimar24
  • profile picture
  • Member

Posted 08 July 2013 - 04:47 AM

Very good day dear Engineers
I have the following question
I have a date field in datetime format
where I store the date and time of the entry of personnel
Now I need to separate the date and time display time only
 
in advance thank you very much for your help
Greetings from bogota Colombia

 

 

Separar  la hora de la fecha  en campo datetime
 
Muy buen dia queridos Ingenieros
Tengo la siguiente pregunta
tengo un campo fecha con formato datetime
donde almaceno la fecha y la hora de la entrada del personal
ahora necesito separar la hora de la fecha  y  solo mostrar  la hora 
 
de antemano muchas gracias por su colaboracion 
Saludos desde bogota Colombia

 

 


Amit Shah
  • profile picture
  • Member

Posted 08 July 2013 - 19:03 PM

It is very simple. You can define the columns of your display that you need (making sure you add the date & time columns too) and on both of them, you can make a column_callback where for the date field, you just return the date extracted from datetime field of yours and other column, just time..


beimar24
  • profile picture
  • Member

Posted 09 July 2013 - 02:47 AM

thank you very much for responding, but I really do not understand you
I have the following,
  database in a field called date
datetime format
and I stored this 17/06/2013 12:08:04
 
and need is only showing 12:08:04
time
 
in advance thank you very much for your help

davidoster
  • profile picture
  • Member

Posted 09 July 2013 - 09:25 AM

As [member=amit shah] suggested just do (on your controller),

 

$crud->callback_column('date', array($this, '_cb_date'));

 

and then 

 

public function _cb_date($value, $row)

{

 $my_time = date("H:i:s",strtotime($value));

 return '<div class="text-left">' . $my_time . '</div>';

}


beimar24
  • profile picture
  • Member

Posted 25 July 2013 - 22:34 PM

Dios los Bendiga muchas gracias por su colaboración

me funciona perfecto 

 

Cordial saludo 


Priss Guerrero
  • profile picture
  • Member

Posted 28 August 2014 - 13:59 PM

Thank you, Davidoster!!!

 

I was with the same problem, but I need the d-m-Y. I just changed and it worked very well! 

 

Big big Thank you!