Jump to content

Profields Table DateTime


Manol
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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>";

 

  • Thanks 1
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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