Failed to parse time string -----Double time specification

Hello,

I have two calc element with this syntax:
Code:
$start = '{orders___OpDate_raw}';
if (!empty($start)) {
   $end = new DateTime($start);
   return $end->modify("-30 days")->format("d/m/Y");
}
else {
   return "";
}
Everything is displaying as it should be but as soon as I want to save the form I get this error message below

DateTime::__construct(): Failed to parse time string (2016-09-14 00:00:00,00:00:00) at position 20 (0): Double time specification

Can my syntax be improve please, any idea why I get this error?

Thanks in advance.
 
Hmmm, you may have to do some extra work to figure out what format the rawe is in. For horribly gory reasons, I think sometimes the raw is a string, and sometimes it's an array of date and time parts, which gets concat'ed into a comma separated pair as a placeholder.

Code:
$start = '{orders___OpDate_raw}';
$start = explode(',', $start);
$start = array_pop($start);

-- hugh
 
Thank you for coming back to me Hugh,

After entering your given code above, I can save the form now but nothing displays on the field. How can I display the date increased of 30 days without having this double time error? Also, the date should always be a working week day.

calc.JPG
 
You'll have to debug it. After loading the form, put this this ...

var_dump($start);exit;

... acter the explode line, and see what it dunmps out (paste it here).

-- hugh
 
Hi Hugh,

Forgive my poor knowledge in PHP and debug terminologies :oops: What do you mean by debugging it and where should I enter the code var_dump($start);exit;? However, after some fiddling, I managed to get this result: string(19) "2016-09-13 10:28:46" and a blank page. Was this that you were looking for?;)
 
Yes, but I need to know where you put it. I said "after the explode() line", so ...

Code:
$start = '{orders___OpDate_raw}';
$start = explode(',', $start);
var_dump($start);exit;
$start = array_pop($start);

... but I would expect it to be an array, not a string at that point. It should then be a string if you put the var_dump at the end.

However, I just noticed I forgot to tell you to return the value. So try this:

Code:
$start = '{orders___OpDate_raw}';
$start = explode(',', $start);
$start = array_pop($start);
return $start;
 
Great! After saving the form, I got this result: 2016-09-13 10:28:46. now
How can I have this date format dd/mm/YY, also that it displays 10 days before the Opdate value and when it is a bank holiday, the next day is selected?

Thanks
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top