warning: date_format() expects parameter 1 to be DateTime, null given in /mnt/sda7/hda/srv/SERVER-PATH/sites/all/modules/date/date_api.module on line 677.

Comments

vasike’s picture

warning: date_format() expects parameter 1 to be DateTime, string given in SERVER-PATH/sites/all/modules/date/date_api.module on line 712.

szy’s picture

Issue tags: +date

warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 677.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 680.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 677.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 680.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 677.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 680.
[...]

... on the event page, and on the front page:

warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 163.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 164.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 733.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 163.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 164.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 733.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 163.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 164.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 733.
[...]

... with active Date, Date API and Date Timezone modules only.

Szy.

szy’s picture

... and on /admin/settings/date-time/formats/custom:

warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 680.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 677.
recoverable fatal error: Object of class DateTime could not be converted to string in /date/date_api.module on line 708.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 677.
recoverable fatal error: Object of class DateTime could not be converted to string in /date/date_api.module on line 708.
warning: date_format() expects parameter 1 to be DateTime, string given in /date/date_api.module on line 712.
warning: date_format() expects parameter 1 to be DateTime, string given in /date/date_api.module on line 712.
recoverable fatal error: Object of class DateTime could not be converted to string in /date/date_api.module on line 708.
warning: date_format() expects parameter 1 to be DateTime, string given in /date/date_api.module on line 712.
warning: date_format() expects parameter 1 to be DateTime, string given in /date/date_api.module on line 712.
warning: date_format() expects parameter 1 to be DateTime, string given in /date/date_api.module on line 712.
recoverable fatal error: Object of class DateTime could not be converted to string in /date/date_api.module on line 708.
warning: date_format() expects parameter 1 to be DateTime, string given in /date/date_api.module on line 712.
warning: date_format() expects parameter 1 to be DateTime, string given in /date/date_api.module on line 712.
warning: date_format() expects parameter 1 to be DateTime, string given in /date/date_api.module on line 712.

... and date formats look like this:

, 17 Feb 2009 10:00:30 +0100 remove
10:00 remove
10:00 e remove
, 17 February 2009 remove
, 17 February 2009 : remove
1234861230 remove
2009-02-17:: remove
20090217 remove

Szy.

mikeskull’s picture

Yep im getting the above on most pages since updating, I have made sure I have set a time zone. plus i get a long list of these errors on the admin/settings/date-time page as well.

# warning: date_format() expects parameter 1 to be DateTime, null given in /modules/date/date_api.module on line 677.
# warning: date_format() expects parameter 1 to be DateTime, null given in /modules/date/date_api.module on line 677.
# warning: date_format() expects parameter 1 to be DateTime, null given in /modules/date/date_api.module on line 677.
# warning: date_format() expects parameter 1 to be DateTime, null given in /modules/date/date_api.module on line 677.
# warning: date_format() expects parameter 1 to be DateTime, null given in /modules/date/date_api.module on line 680.
# recoverable fatal error: Object of class DateTime could not be converted to string in /modules/date/date_api.module on line 708.
# warning: date_format() expects parameter 1 to be DateTime, string given in /modules/date/date_api.module on line 712.
# warning: date_format() expects parameter 1 to be DateTime, string given in /modules/date/date_api.module on line 712.
# warning: date_format() expects parameter 1 to be DateTime, string given in /modules/date/date_api.module on line 712.
# recoverable fatal error: Object of class DateTime could not be converted to string in /modules/date/date_api.module on line 708.
# warning: date_format() expects parameter 1 to be DateTime, string given in /modules/date/date_api.module on line 712.
# warning: date_format() expects parameter 1 to be DateTime, string given in /modules/date/date_api.module on line 712.
# warning: date_format() expects parameter 1 to be DateTime, string given in /modules/date/date_api.module on line 712.
# warning: date_format() expects parameter 1 to be DateTime, null given in /modules/date/date_api.module on line 680.
# warning: date_format() expects parameter 1 to be DateTime, null given in /modules/date/date_api.module on line 680.
# warning: date_format() expects parameter 1 to be DateTime, null given in /modules/date/date_api.module on line 680.

just a small snippet.

karens’s picture

Whats going on? I don't see this anywhere.

Start by emptying all the caches at admin/settings/performance.

Then edit the date fields. See if everything looks ok there and re-save it, just to be sure.

Then pull up any views that use date fields and double check that all the date fields, filters, or arguments look right and re-save them just to be sure. Empty the Views cache by using the Views Tools tab and clicking the button that says 'Clear cache' (or whatever it says).

Then see where things stand.

karens’s picture

Wait, all the messages are about formats, so I checked the formats page and I see them too. I'm investigating....

karens’s picture

Status: Active » Fixed

Found the problem and just committed a fix. It's a very small but fatal typo in some change I made yesterday.

If you want to manually fix your code the change is on line 708 of date_api.module in the date_format_date() function, change:

case '\\':
  $date .= date_format($date, $c);

to:

case '\\':
  $datestring .= date_format($date, $c);
szy’s picture

Still:

warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 161.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 162.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 733.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 161.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 162.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 733.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 161.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 162.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 733.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 161.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date/date.theme on line 162.
warning: date_format() expects parameter 1 to be DateTime, null given in /date/date_api.module on line 733.
[...]

Szy.

szy’s picture

Status: Fixed » Active

(with the last dev - from February 18, 2009 - 01:06 +0100)

Szy.

szy’s picture

  $start = date_format($start_date, DATE_FORMAT_DATETIME);
  $end = date_format($start_date, DATE_FORMAT_DATETIME);

... so, is $start equal to $end?

Szy.

karens’s picture

#9 is a different error and I have no idea how to reproduce it. I need to know what you were doing when you saw these errors.

#10 is obviously a bug, but it didn't cause these errors.

karens’s picture

Status: Active » Fixed

I never got these particular messages, but there were some problems in the handling of the 'time ago' format that I just fixed. They are the likely cause of messages like the ones in #9.

szy’s picture

Yes, now there is no error displayed, thank you! :]

But... all my CCK data fields in 'time ago' format disappeared from views, too. Other
formats are displayed correctly.

Szy.

szy’s picture

To be precise: the fields do appear with dev from February 24, 2009 - 01:05 +0100,
and they disappeared with date.module and date.theme taken right from CVS
(today 10:36, 10:37 +0100).

Szy.

karens’s picture

I can see the new fields fine in Views after the changes, I need more information about how to get your error (and try editing and re-saving your fields and your view first to see if that helps).

Also please don't add in other unrelated issues like your reference to a comment in another issue, each issue is supposed to be about one thing so I can close it when it is fixed. If you keep piling other things in I can never get anything closed and everyone else gets confused about what exactly is broken and what is fixed.

szy’s picture

I have edited all the possible things: the CCK field, the node type, and the view.

I don't think my view is unusual:

$view = new view;
$view->name = 'Imprezy_Najblizsze_Front';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'title' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
  'field_miejsce_nid' => array(
    'label' => '',
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'plain',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_miejsce_nid',
    'table' => 'node_data_field_miejsce',
    'field' => 'field_miejsce_nid',
    'relationship' => 'none',
  ),
  'field_data_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'format_interval',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_data_value',
    'table' => 'node_data_field_data',
    'field' => 'field_data_value',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'field_data_value' => array(
    'order' => 'ASC',
    'delta' => -1,
    'id' => 'field_data_value',
    'table' => 'node_data_field_data',
    'field' => 'field_data_value',
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'status' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'relationship' => 'none',
  ),
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'impreza' => 'impreza',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
  'date_filter' => array(
    'operator' => '>',
    'value' => array(
      'value' => NULL,
      'min' => NULL,
      'max' => NULL,
      'default_date' => 'now',
      'default_to_date' => '',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'date_fields' => array(
      'node_data_field_data.field_data_value' => 'node_data_field_data.field_data_value',
    ),
    'date_method' => 'OR',
    'granularity' => 'second',
    'form_type' => 'date_select',
    'default_date' => 'now',
    'default_to_date' => '',
    'year_range' => '-3:+3',
    'id' => 'date_filter',
    'table' => 'node',
    'field' => 'date_filter',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
  'role' => array(),
  'perm' => '',
));
$handler->override_option('header_format', '1');
$handler->override_option('header_empty', 0);
$handler->override_option('footer_format', '1');
$handler->override_option('empty_format', '1');
$handler->override_option('items_per_page', 9);
$handler->override_option('use_pager', '0');
$handler->override_option('style_plugin', 'list');
$handler->override_option('style_options', array(
  'grouping' => '',
  'type' => 'ul',
));
$handler->override_option('row_options', array(
  'inline' => array(),
  'separator' => '',
));

As I wrote before: all data formats are displayed, except of 'time ago'. Then field
looks like this:

<div class="views-field-field-data-value"> 
                <span class="field-content"></span> 
  </div>

This happens when applying your fixes in data.theme and data.module from today,
10:36, 10:37 +0100. Before them field is visible.

Szy.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

heathergaye’s picture

Version: 6.x-2.x-dev » 6.x-2.0
Status: Closed (fixed) » Active

Hi, I suspect the problem (or at least, a related problem) is that there's a table - date_format - which is the same name as a mysql function. I got an error when I tried to install the latest update & ran the sql manually. Obviously this isn't going to pose a problem if you've set a table prefix.

karens’s picture

Status: Active » Fixed

No, there is no problem. I don't use prefixes and had no trouble. The table name is not used as a function anywhere.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ldekay’s picture

Version: 6.x-2.0 » 6.x-2.4
Component: Date API » Miscellaneous
Status: Closed (fixed) » Active

I've had the same problem crop up 3 times in the past month. W hen I created a new node I used date picker to select start and end dates. The dates were there in the date fields before I Saved, but after the Save I got the errors above, and there were no dates in the node page display. When I edited the node again there weren't any dates in the start/end date fields. I reentered the dates, saved, same result. The three logged error messages are:

error php Apr 20 2010 - 11:07pm date_format() expects parameter 1 to be DateTime, null given in /home/content/o/n/c/oncorg/html/sites/all/modules/signup/includes/date.inc on line 489.
> error php Apr 20 2010 - 11:07pm date_modify() expects parameter 1 to be DateTime, null given in /home/content/o/n/c/oncorg/html/sites/all/modules/signup/includes/date.inc on line 488.
> error php Apr 20 2010 - 11:07pm date_timezone_set() expects parameter 1 to be DateTime, null given in /home/content/o/n/c/oncorg/html/sites/all/modules/signup/includes/date.inc on line 485.

First two times the problem cropped up I bumbled through several date/time related set-up pages and fixed it, but I didn't know how. This latest one I methodically went through and found that it cleared up when I went to Site Configuration> Date and Time and did a 'Save Configuration' on the Formats tab without changing any of the settings. The date started working again and the Repeats tab reappeared on the content page.

Using Date 6.x-2.4 with Date Popup and Date Repeat API enabled. Also using Calendar 6.x-2.2 it that matters.

dww’s picture

Version: 6.x-2.4 » 6.x-2.0
Status: Active » Closed (fixed)

@Idekay: You're experiencing a new bug: #518816: warning: date_format() expects parameter 1 to be DateTime. Please apply the patch there until it's committed to CVS.

@all: This particular issue has been a source of much trouble, and the particular problems reported here were fixed. New bugs need new issues, so I'm just going to lock comments here to prevent anyone else from re-opening this. ;)

Cheers,
-Derek