Juergen Posted September 22, 2016 Posted September 22, 2016 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: 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
kongondo Posted September 22, 2016 Posted September 22, 2016 PW 3? Namespace maybe? \Datetime..maybe..?.....just guessing...Haven't used NS b4 1
Juergen Posted September 22, 2016 Author Posted September 22, 2016 Thanks at all, I have solved it like this: <?php namespace ProcessWire; use \DateTime; and then $end = new \DateTime($enddate);
LostKobrakai Posted September 22, 2016 Posted September 22, 2016 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(); 4
dragan Posted April 10, 2019 Posted April 10, 2019 Just stumbled over this yesterday, when I wanted to do a simple date-difference calculation...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now