⚠ 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

Php function to display month and day



beimar24

beimar24
  • profile picture
  • Member

Posted 29 November 2013 - 16:18 PM

In English

 

Very good days Appreciated Engineers
 
I have a field called fechaCumple in my database
formatted date
 
in my view now I want to show only the day and month of that date I have in my database
 
would be something like mysql date (field, dd, mm)
 
Now I would like to be able to do in Grocery Crud Using PHP
 
something like
 
$ crud-> display_as (date ('fechaCumple, mm, dd)', 'Birthday');
But it works for me
 
thank you in advance any collaboration
 
regards
Beimar

 

 

En español 

 

 

Muy buenos dias apreciados Ingenieros 
 
Tengo un campo llamado fechaCumple en mi base de datos 
con formato date
 
ahora quiero en mi vista solo mostrar el dia y el mes de esa fecha que tengo en mi base de datos 
 
en mysql seria algo asi  date(campo,dd,mm)
 
Ahora me gustaria poderlo hacer en  Grocery Crud Utilizando PHP 
 
Algo asi
 
$crud->display_as( date('fechaCumple,mm,dd)','Cumpleaños');                        
Pero no me funciona 
 
agradezco de antemano cualquier colaboracion 
 
Cordial saludo 
Beimar

 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 29 November 2013 - 20:48 PM

Hi beimar24

 

There is a simple way for the same - use

$crud->callback_column('fechaCumple', array($this, 'formatBday');
......
function formatBday($value, $row) {
       return date('m, d', strtotime($value));
}