Jump to content

Recommended Posts

Posted

Hello @ all,

I have created a module which works with dates.

I have the following 2 lines of code in my module:

268:                    $enddate = '2006-12-12';
269:                    $end                  = new DateTime($enddate);

If I check the module with Tracy it gives me always the following error:

Screenshot_2.jpg

I dont know why the new DateTime class will not be found because it is a standard PHP class. I have added the PW namespace at the top of the module, but it doesnt make any difference whether I add it or not.

I am not a PHP  pro, so can somebody give me a hint why this leads to an error message? I need this to create time intervals afterwards.

Best regards

Posted

The use statement does nothing in you snippet. If you want to use "use", then like this:

<?php namespace ProcessWire;

use DateTime;

$date = new DateTime();

 

  • Like 4
  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...