I've read other posts about similar warning messages, but none are quite the same as this. I'll try to be as complete and as specific as possible.
I'm using a CCK Date field (not timestamp) with the text field widget (not pop-up). I've tried setting my time zone to America/New York and US/Eastern. Multiple not selected. Required: yes.
I have the granularity for the field set to year only so there is no time zone conversion set for the field.
When I view or edit/submit my node with the date field I get 12 errors in the following form:
warning: date_format() expects parameter 1 to be DateTime, null given in .../modules/date/date_api.module on line 501.
The node does display a year, but it is always one year less than the one I enter, i.e. if I input 1990, the field displays 1989. Since I had originally created these fields using date version 5.x-1.8, I thought maybe there was a problem with the upgrade to the new version, so I tried creating a new date field with the same details as the original one. I get the same results on that too.
Comments
Comment #1
anthonym commentedTried troubleshooting this some more, but haven't had any success. I tried changing the date field type to calendar pop-up, and that just made things worse. Apparently, you can not use the pop-up calendar to select just a year. So I went back to just the text field. Interestingly, everytime I resubmit the node it subtracts 1 from the value in my date (year) field. What is going on here?
Changing priority to critical.
Also, forgot to mention to mention before, I have PHP version 5.2.5.
Comment #2
karens commentedI think you are saying there is a problem with a year-only date, right? Changing title to be more clear.
Comment #3
anthonym commentedYes, it is a year only date. I had no problem with this in earlier versions of the Date module. I just installed the newest dev versions of Date and Token, but the problem persists as described above.
Comment #4
karens commentedI know what the problem is, just thinking about the best fix. Basically, you need a complete date in a number of places for element handling, so we have to create a psuedo date for that purpose and then remove the parts we don't want when we save it. The current code is using a zero for the month and day and when you make that into a date using date_create() it assumes you mean the last month of the previous year and the last day of the previous month, so you get november 30 of the previous year. I just need to figure out the best place to add dummy values to get a correct date and remove them before I save the data.
Comment #5
anthonym commentedKarenS,
Any new ideas on how to fix this?
I suppose for the time being I could just use a text field for my year-only date, but at some point, for some nodes, I might like to include a month and day as well.
Comment #6
karens commentedI think I've got this working right in the latest commit. Hopefully :)
Comment #7
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #8
Lobidu commentedHello,
Looking for a solution on a problem, I found this post. I have the same problem with my 7.x-version. If I have a year-only field, it shows always one year less than I put in. I have no error messages, but it seems to be the same problem as it was with this earlier version.
Comment #9
karens commentedPlease do not re-open old issues and change the version. The code (and any associated problems) in 5.2 it totally and completely different then in D7.