Hi
I am stuck with dates. I have a node form where the user can enter a date - and I cna even store it correctly! But when I try to edit the node all comes crashing down around me :(
Details:
In my form I generate the date field like this:
<?php
$form['startdate'] = array(
'#type' => 'date',
'#title' => t('Start Date'),
'#default_value' => $node->startdate,
'#description' => "The date on the competition will be open to entries.",
'#required' => TRUE,
);
?>
It shows up fine on the page and I can enter the date fine.
I store it in my database in a field " startdate int(11) NOT NULL " using this code in my insert hook:
<?php
db_query("INSERT INTO fhsstadmin_competition (nid,startdate,enddate) VALUES (%d,%d, %d)",
$node->nid,
mktime(12,0,0,$node->startdate['month'],$node->startdate['day'],$node->startdate['year'])- $user->timezone,
mktime(0,0,0,$node->enddate['month'],$node->enddate['day'],$node->enddate['year'])- $user->timezone
);
?>
And when I view it using:
<?php
format_date($node->startdate,'short')
?>
It looks fine when I do this. So far so good. But when I try to edit the node I get an error
Fatal error: Cannot create references to/from string offsets nor overloaded objects in /var/www/FHSST2/includes/form.inc on line 310