I had a project where on a node type I wanted a date field that would save only the year.
So I created a new date field on the node type and selected the field type to be Date (Unix timestamp).
Next on the Field settings page I started to uncheck the Date attributes to collect, leaving only the year.
And here is were the problem occurs.
Once I removed the Hour component, the Time zone handling select-list disappears, with a default value of "Site's time zone".
This later lend to problems with the date values that were being saved in the Database since my website's timezone is GMT +2, so actually by selecting 2015 it would result in 2014 December 30 22:00 being saved in the Database.
I believe that the default value of the Time zone handling for the field type: Date (Unix timestamp), should be UTC, since it only really makes sense to have a timestamp based on UTC.
Comments
Comment #1
martichka5 CreditAttribution: martichka5 commentedHello,
I think I have a similar problem. When we collect only year, month and day without hour, the displayed date (in format "time ago") is not shown properly. The date is calculated with the previous date. The same happens when we use strtotime function for example.
entered date = 2015-03-26 after strtotime = Wed, 25 Mar 2015 23:00:00 GMT
Any help would be appreciated.
Thank you in advance!
Comment #2
maximpodorov CreditAttribution: maximpodorov commentedI suggest to change 'tz_handling' setting for timestamp fields. Timestamps are always in UTC, so 'site' value seems appropriate one for all timestamps.
The patch forces this setting change upon field settings editing (no hook_update yet).
Comment #4
jonloh CreditAttribution: jonloh as a volunteer commentedI've tested it and it seems to be filtering accurately now.
Here's an additional step which I did in order to get it to work - Once you patch the file, re-save your nodes which have the date field that needs to be filtered in Views.
I would suggest for others to test the patch to ensure it work fine in different scenarios.
Comment #5
rooby CreditAttribution: rooby commentedThis also fixes my problem of trying to compare a year/month/day unix timestamp with 'today' in a view.
Comment #6
Liam MorlandUntested re-roll of #2.
Comment #8
rooby CreditAttribution: rooby commented[EDIT] Whoops, I didn't see the testbot
Comment #9
Liam MorlandPatch #6 with test error fixed.
Comment #10
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 2 year old patch in #9 to date_admin.inc still applied cleanly to 7.x-2.x-dev. Is anyone able to confirm this issue is ready for RTBC?