DateHelper object loading empty

Permalink
concretee5.6.3.3
This is a real strange one. I am trying to use "$date = Loader::helper('date');".
After it loads, I am testing with the command "print_r($date);".
What is printed to the page is "DateHelper Object ()".
It appears that php is not extending class "DateHelper" to the core's class "Concrete5_Helper_Date". I double checked all files' permissions and they are correct. The first few times trying my controller code, I got an error message that "/path-to-site/concrete/helpers/'date'.php" could not be found. I tried removing the single quotes around 'date' but that caused another error down the line. I put the command back the way it should be with the quotes and then it loaded but it's loading empty.

Anyone have any ideas as to what could cause this?

Also, I checked the Apache error log and php isn't throwing any errors. (php.ini errors are turned on).

ThomasJ
 
hutman replied on at Permalink Reply
hutman
Can you check and make sure that you do not have a date.php in the root helpers folder? This almost looks like somebody created an override file incorrectly.
ThomasJ replied on at Permalink Reply
ThomasJ
I don't have a helpers directory in my root.This is what is in concrete/helpers/date.php that came with concrete5.6.3.3;
<?php
defined('C5_EXECUTE') or die("Access Denied.");
class DateHelper extends Concrete5_Helper_Date {}

It seems okay but it's just not extending the core date helper.
hutman replied on at Permalink Reply
hutman
After checking this out I believe this is the normal behavior. If you try doing something like

$date = Loader::helper('date');
echo $date->getLocalDateTime();


Does it print out the current server date/time?

I don't quite understand what you are trying to do with the Date Helper but what you are seeing appears to be normal behavior, print_r does not print out the object's functions.
ThomasJ replied on at Permalink Reply
ThomasJ
Thanks for this.

I had moved on without fixing this because of time constraints and I will have to go back to this, maybe tomorrow, to check this out. What you are showing here looks like the proper commands to get the date from the date helper.

I will try;
$dt = Loader::helper('date');
$date = $dt->getLocalDateTime();
ThomasJ replied on at Permalink Reply
ThomasJ
I finally was able to get back to fixing this problem. My syntax was okay but it turns out from cutting and paisting "$date->getLocalDateTime(‘now’, ‘F d, Y’);" directly from the concrete5 information page, the single quotes turned out to be something other than single quotes that was causing my errors.