Get following php error message after upgrading on April 14 to latest dev version

date_format() expects parameter 1 to be DateTime, string given in /home/sitename/public_html/sites/all/modules/date/date_api.module on line 710.

I returned to earlier April 10 version and error goes away.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

theohawse’s picture

I have this exact problem, but is being caused by date popup + I18n modules

warning: date_format() expects parameter 1 to be DateTime, string given in J:\wamp\www\casaresources\sites\all\modules\date\date_api.module on line 678.
warning: date_format() expects parameter 1 to be DateTime, string given in J:\wamp\www\casaresources\sites\all\modules\date\date_api.module on line 710.
warning: date_format() expects parameter 1 to be DateTime, string given in J:\wamp\www\casaresources\sites\all\modules\date\date_api.module on line 710.
warning: date_format() expects parameter 1 to be DateTime, string given in J:\wamp\www\casaresources\sites\all\modules\date\date_api.module on line 710.
warning: date_format() expects parameter 1 to be DateTime, string given in J:\wamp\www\casaresources\sites\all\modules\date\date_api.module on line 710.
warning: date_format() expects parameter 1 to be DateTime, string given in J:\wamp\www\casaresources\sites\all\modules\date\date_api.module on line 710.
theohawse’s picture

Guess thats what I get for going to the dev version, was tying to get the date translated, but hadn't enabled the date locale.

Reverted to recommended version and warning disappeared.

recrit’s picture

I had the same error and noticed that on the node form the date popup format description was blank. The attached patch to the latest dev 2010-04-14 fixes this error.

recrit’s picture

Status: Active » Needs review

changing to needs review

movinr8along’s picture

Title: Erro after upgrading to latest dev version on April 14 » Error after upgrading to latest dev version on April 14

This patch worked for me.

webwriter’s picture

Patch confirmed working for me.

butler360’s picture

Patch works for me.

recrit’s picture

Status: Needs review » Reviewed & tested by the community

bumping to tested in hopes to get patch applied

Junro’s picture

Status: Reviewed & tested by the community » Needs work

Hello, patch doesn't work for me.

Maybe it's because I have the warning on line 681 and 688 too.

warning: date_format() expects parameter 1 to be DateTime, string given in /home/pariscin/www/sites/all/modules/date/date_api.module on line 681.
warning: date_format() expects parameter 1 to be DateTime, string given in /home/pariscin/www/sites/all/modules/date/date_api.module on line 710.
warning: date_format() expects parameter 1 to be DateTime, string given in /home/pariscin/www/sites/all/modules/date/date_api.module on line 688.

gozigzag’s picture

I am getting similar warnings after updating to dev. version- more than 50 total - such as : warning: date_format() expects parameter 1 to be DateTime, string given in C:\wamp\www\go8\sites\all\modules\date\date_api.module on line 678. I tried the patch on 3. No change.

I get this when I go and try to edit a node, this is the only time I've noticed it. And the description for the date format for the CCK date fields on the node edit page is not displaying correctly. Instead of showing Format: 04/24/2010 it shows this: Format: , // - :

I've tried going through each date field in the admin, content type, manage fields settings - making minor changes, re-saving each field. Did not help.

mayerwin’s picture

Same problem here with dev version

jared12’s picture

Patch from #3 seems to have solved this problem for me. Thanks!

avibrazil@gmail.com’s picture

Worked for me too. Thanks for the patch !

amariotti’s picture

Status: Needs work » Reviewed & tested by the community

Patch worked for me too. I remember patching this last time....it'd be nice to get this committed to the dev version so I don't have to track this down again. :)

Junro’s picture

Status: Reviewed & tested by the community » Needs work

read #9

recrit’s picture

digging deeper to find if any other part of the date module was erroneously using date_format_date.

searching for signature from date_popup.module error on unmodified date module:

grep -rn "date_format_date(date(" ./*

Result:
date_api_elements.inc:150
date_popup/date_popup.module:259

My thoughts: people who use date popup were fixed on initial patch, everyone else continued to see this. its the exact same error, most likely some copy-pasting going on.

Everyone who didn't get fixed on first one, try this one and report back.

jcmarco’s picture

Status: Needs work » Needs review

This patch solves all the errors I had when editing forms with date fields.
Thank you.

ali_b’s picture

it works, thank you

alippai’s picture

Status: Needs review » Reviewed & tested by the community

patch #16 works for me

Junro’s picture

Status: Needs work » Fixed

Fixe in the last dev. version (6.x-2.x-dev (2010-mai-02).

Sorry, the last dev version doesn't fixe this problem.

tchurch’s picture

Status: Reviewed & tested by the community » Needs work

Not working for me. I have -dev version from 2-5-2010 installed.

warning: date_format() expects parameter 1 to be DateTime, string given in /home/sites/.co.uk/public_html/central/sites/all/modules/date/date_api.module on line 678.
warning: date_format() expects parameter 1 to be DateTime, string given in /home/sites/.co.uk/public_html/central/sites/all/modules/date/date_api.module on line 710.
warning: date_format() expects parameter 1 to be DateTime, string given in /home/sites/.co.uk/public_html/central/sites/all/modules/date/date_api.module on line 710.
warning: date_format() expects parameter 1 to be DateTime, string given in /home/sites/.co.uk/public_html/central/sites/all/modules/date/date_api.module on line 710.
warning: date_format() expects parameter 1 to be DateTime, string given in /home/sites/.co.uk/public_html/central/sites/all/modules/date/date_api.module on line 710.
warning: date_format() expects parameter 1 to be DateTime, string given in /home/sites/.co.uk/public_html/central/sites/all/modules/date/date_api.module on line 710.

Junro’s picture

Status: Fixed » Needs work

Patch #16 works, thanks recrit :)

alippai’s picture

Status: Needs work » Reviewed & tested by the community

Please don't set as needs work, if patch works. It's not fixed in dev, that's true. (02-05-2010 version adds only Czech translation)

recrit’s picture

this fixes the dev version the patch was specified to fix... its not valid for any future dev unless re-evaluated that nothing has changed in the new dev. patches shouldn't have multiple versions to chase the module dev if the maintainer does not apply the patch.

If using the correct dev and this patch AND still see this error, the issue could be in ANY module that calls date_format() incorrectly, not necessarily the date module itself.

jlmeredith’s picture

This patch worked for me against the latest dev build.

inforeto’s picture

Patch from #16 worked for me against the dev build of May 1st.

jenna.tollerson’s picture

Patch worked for me against 2010-May-02 dev build. Freaking awesome work, this has been driving me batty.

Witch’s picture

subscribe

tribe_of_dan’s picture

Patch from #16 seems to have worked for me. Thank you

dww’s picture

Confirming that this bug still exists in DRUPAL-6--2 branch, and that patch #16 fixes it and looks like the proper solution. It'd be nice to get this into CVS so that people don't keep a) hitting the bug and b) reopening old similar-looking issues. I just searched for this and found quite a few issues where things were getting ugly. ;)

Thanks for the great module KarenS!

Thanks for the patch, recrit!

Cheers,
-Derek

m.sant’s picture

Confirming that this bug persists in version 6.x-2.x-dev installed today.

The patch works.

Regards,

Marco

Danny Englander’s picture

When I try to apply the patch, I get prompted what file to patch, can anyone shed light on which file to patch? thanks.

dww’s picture

Title: Error after upgrading to latest dev version on April 14 » "date_format() expects parameter 1 to be DateTime, string given" warnings when creating/editing nodes with date fields

@highrockmedia: Start in the root of the "date" module and use patch -p0 < date-772180-element-description-1.patch
See http://drupal.org/patch/apply for more.

Also, giving this a better title to be more visible for other users experiencing the same problem.

dww’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Actually, I just searched through the date issue queue and since there are a lot of duplicate reports of this, I wanted to consolidate everything into the oldest open issue about this:

#518816: warning: date_format() expects parameter 1 to be DateTime

This research revealed another issue for the same bug with a different, perhaps better patch. So, please check that out, too:

#518816-5: warning: date_format() expects parameter 1 to be DateTime

Danny Englander’s picture

@dww - Ok, that command works, thanks! I no longer get the specific error I was having here: http://drupal.org/node/808242

cerup’s picture

#16 worked.

Based upon all the confirmations, can we get this committed to the latest dev release?

dww’s picture

No, we can't. Once an issue is marked "duplicate", please stop commenting here. Join us in the earlier issue that I linked when I marked this duplicate...