Manol Posted May 30, 2018 Posted May 30, 2018 I got a field called entrega and defined as DateTime (Profields Table) with the following parameters dateInputFormat=Y-m-d timeInputFormat=H:i dateOutputFormat=Y-m-d timeOutputFormat=H:i datepicker=3 defaultToday=0 yearRange=-10:+10 placeholder= textformatters=TextformatterEntities default= when I try to save same data with $newRow->entrega = date("Y-m-d H:i"); I get 2018-05-30 00:00 if I do echo date("Y-m-d H:i"); I get the right date and time. Thanks.
Autofahrn Posted May 31, 2018 Posted May 31, 2018 When I set DateTime fields from API I just use the unix timestamp like: $newRow->entrega = time(); Well, doesn't help if your time source is a string. 1
Autofahrn Posted May 31, 2018 Posted May 31, 2018 Can you give me more code context? I've just added that to my previous test code and it works quite well: <?php namespace ProcessWire; $test = $page->protabla->makeBlankItem(); // getNew(); $test->name = date('D, d M Y H:i:s'); $test->notes = 'my note'; $test->entrega = time(); // date("Y-m-d H:i"); // $test->save(); $page->of(false); // required for page save $page->protabla->add($test); $page->save('protabla'); // only save that field $page->of(true); $content = "<h4>{$page->title}</h4>"; $content .= "<table>"; foreach($page->protabla as $pt) { $content .= "<tr><td>{$pt->name}</td><td>{$pt->notes}</td><td>{$pt->entrega}</td></tr>"; } $content .= "</table>"; 1
Manol Posted May 31, 2018 Author Posted May 31, 2018 I've changed the type to Date and back to DateTime and now is working as it should. Thanks, hope I can help you in the future. 1
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