⚠ 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

comparing two dates



zaang

zaang
  • profile picture
  • Member

Posted 18 January 2019 - 13:18 PM

Ok so I have two dates for each entry, planned date and actual date. I want to compare these two and change text color of the actual date to red if it is later than the planned date.

 

What I have so far:

 

$crud->callback_column('actualstart',array($this,'_RedMarker'));

 

and

public function _RedMarker($value, $row)
	{
		if($row->actualstart>$row->plannedstart)
		{
			return '<span style="color:red"><span>'.$row->actualstart;
		}
		else
		{
			return $row->actualstart;
		}
	}

My problem is When I use the callback it seems to get the date in Y-m-d format, then tries to compare it planned date which is in d-m-Y format. Which obviously gives wrong results, and on top of that the date format on the table also changes to Y-m-d. (See attached)

 

How can I get the date in d-m-Y format or is there way to change grocery crud date format to Y-m-d (). If you have any other solutions im open to suggestions.


lcoulon

lcoulon
  • profile picture
  • Member

Posted 23 January 2019 - 12:08 PM

I don't have the solution,

 

I am facing exactly the same problem when applying Bootstrap 4 CSS class on a date field.

 

Is there any trick to get expected date format displayed ?