Return date from MySQL BD

wagner.nardin

New Member
One more question.

With Joomla version 3.8.1 and Fabrik version 3.8

I'm using the calc element, to capture the date of each user's last visit to the table 'jos_users'.

With the code below, the return is always given with the date 31.12.1969 21:00
PHP:
return date('d.m.Y H:i', strtotime('{jos_users___lastvisitDate}'));

How can I solve this problem?
 
Try adding _raw to the placeholder.

If that doesn't work, var_dump it:

Code:
$myDate = '{jos_users___lastvisitDate_raw}'
var_dump($myDate);exit;
if (FabrikWorker::isDate($myDate)) {
   $myDate = new DateTime($myDate);
   return $myDate->format('d.m.Y H:i');
}
return 'Not a date!';

Load the form, it should just show a blank page with a date string. If the string looks OK, remove the var_dump() line and try again.

Note that I've modifed the handling of the date a little, to use a helper function Fabrik provides to make sure a string is a date in a format PHP's DateTime will accept, then uses the DateTime object to do the formatting.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top