Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
On all my content types any field that is a Date (ISO format) when I save the date time the time always rounds up or down to the nearest 5 min increment. The fields are all textfields no popups. I haven't seen any settings where a time increment is set. Any advice?
Comment | File | Size | Author |
---|---|---|---|
#56 | date-date_text-1-minute-increments-1355256-56.patch | 815 bytes | jgullstr |
#54 | Screenshot_4.jpg | 94.79 KB | kevinus |
#54 | Screenshot_3.jpg | 129.02 KB | kevinus |
#54 | Screenshot_2.jpg | 55.31 KB | kevinus |
#54 | Screenshot_1.jpg | 101 KB | kevinus |
Comments
Comment #1
KarenS CreditAttribution: KarenS commentedThe increment is controlled in the field settings. There is a collapsed fieldset called advanced settings that you can open up to see what you can control.
Comment #2
mikeg333 CreditAttribution: mikeg333 commentedI think this is a bug not a support request. If I change the date field to a select list or popup I have the option of a time increment for minutes in the advanced settings. If I change it to a textfield there is no time increment in the settings but it is still incrementing the time I enter to the nearest 5 min mark.
Comment #3
mikeg333 CreditAttribution: mikeg333 commentedIf I add "date_text" to the array in line 297 of date_admin.inc I'm now able to see an increment option which after setting fixes my issue.
Comment #4
KarenS CreditAttribution: KarenS commentedThere should be no way to create a text date that has a 5 minute increment. How did that field get created in the first place?
Comment #5
KarenS CreditAttribution: KarenS commentedI never got a response to my request for more information, so I'm assuming it is no longer an issue or the reporter doesn't care about this any more.
Comment #6
SKapThe field is just a standard date field with the textfield widget. If you enter a specific time - I tried 05:38, for example - upon saving, it changes to 05:30 or 05:45. Mikeg333 is correct though, if you change to the select list or popup widget, you have the option of choosing how this works. I see this as a bug, personally.
Comment #7
sjs CreditAttribution: sjs commentedI encountered this bug too, although for me it was 15min, not 5min. The fix suggested in #3 works for me too, although in 7.x-2.3 it is line 316.
I think this bug might be due to a default 15 minute increment set in function date_field_widget_info().
Comment #8
kking CreditAttribution: kking commentedI'm also having this issue but on seconds, not minutes. I'm trying to save a time/date as a UNIX timestamp and its rounding to the nearest 15 seconds
Text input field. Data attributes to collect: all fields.
2012-04-25 17:30:08 => 1335389415
2012-04-25 17:30:15 => 1335389415
2012-04-25 17:30:22 => 1335389415
2012-04-25 17:30:23 => 1335389430
2012-04-25 17:30:30 => 1335389430
2012-04-25 17:30:37 => 1335389430
Comment #9
sender CreditAttribution: sender commentedI can confirm this bug. Textfield widget is applying increments, but has no UI element to control this. The select widget does, as indicated, and this setting will be used by the textfield widget.
It's kind of a big deal, b/c while adding this field and keeping all default values, one ends up with a situation that behaves unpredictable.
Comment #10
lucor CreditAttribution: lucor commentedI have the same issue. Version 7.x-2.5 on unix timestamp with minute granularity.
Textfield widget apply increments, if I use select list only the following values are avalaible: 00, 15, 30, 45.
I've unable to find a way to modify these settings with the UI.
Comment #11
ioannis.cherouvim CreditAttribution: ioannis.cherouvim commentedI confirm this on 7.x-2.5 with:
- Field: Date
- Widget: Text field
- Collect: Year Month Day Hour Minute Second
Comment #12
powery CreditAttribution: powery commentedI have the same issue. How to fix it?
Comment #13
DevElCuy CreditAttribution: DevElCuy commentedI confirm this bug. The date you input is being rounded to the nearest quarter hour.
The funny thing here is that if you set a granularity down till seconds, they are not rounded, just the minutes are being rounded.
Comment #14
DevElCuy CreditAttribution: DevElCuy commentedEDITED:
Just tested again and can confirm that seconds are being rounded too, both minutes and seconds are being rounded to the closest quarter. I have tested with normal date fields using text field widget.
And just noticed that the "Select list" widget has minutes and seconds in quarters. So perhaps the round function is being called in the text field widget, when it should not be the case.
Comment #15
DevElCuy CreditAttribution: DevElCuy commentedConfirmed in stable version, this bug is critical.
Comment #16
DevElCuy CreditAttribution: DevElCuy commentedHere is a patch for current stable release. If you already have a field, then follow this instructions to fix the issue:
- Switch your date field to "Select list" widget, to make the option "Time increments" available in your field settings.
- Set "Time increments" to "1 minute", it works for seconds too (should be one setting for second and another for minutes though)
- Save
- Switch your field widget back to "Text field"
NOTE: Attached patch will affect new fields only.
Comment #17
DevElCuy CreditAttribution: DevElCuy commentedAttached patch against 2.x-dev
Comment #19
barraponto CreditAttribution: barraponto commentedI guess this approach avoids the issues that breaks the tests...
Comment #20
barraponto CreditAttribution: barraponto commentedGo bot!
Comment #21
DevElCuy CreditAttribution: DevElCuy commentedWorks like a charm!
Comment #22
DevElCuy CreditAttribution: DevElCuy commentedComment #23
KarenS CreditAttribution: KarenS commentedActually the patch needs a couple things. It changes the default increment for Date Popup widgets to 1, which is wrong, and it needs to include an update hook to fix the increment values for existing fields.
So the updated patch would be:
Comment #24
KarenS CreditAttribution: KarenS commentedOops, that patch was a little off, the basic default should be 15, then just reset the value for date_text.
http://drupalcode.org/project/date.git/commit/3eb62b6
http://drupalcode.org/project/date.git/commit/89dd330
Comment #25
Mark Theunissen CreditAttribution: Mark Theunissen commentedWhen is the next stable release due? This bug is huge - in our system nodes are imported programmatically, and every time someone opens the node/edit form and saves it, through the admin interface, any data in the date fields is destroyed by being rounded off. We're still in development, thank goodness, but this could potentially hose someone's data and a stable release should be a priority.
Comment #26
barraponto CreditAttribution: barraponto commentedThis bug report is already critical, so let's ask for a new release and help with any possible release blocker. @Karen?
Comment #28
ambientdrup CreditAttribution: ambientdrup commentedThis patch is not working for me. I applied the patch via #24 and I have pop up calendar as the widget. The times still only increment by quarters. In other words I can't put in 5:16 p.m. It defaults to 5:15 p.m.
So does this patch work?
-Trevor
Comment #29
ambientdrup CreditAttribution: ambientdrup commentedOk I see this only works with text field widget. Can we make this patch work with pop up calendar widget as well?
-Trevor
Comment #30
ambientdrup CreditAttribution: ambientdrup commentedActually after testing this, the patch fails. When I switched to text field widget I then entered 5:12 p.m. as my time. That worked. However when I save the node the value that gets inserted and saved into the node (and db) is 5:15 p.m.:
Feb 18 2010 - 5:15pm
So the data is not saving in 1 increments even with the text field.
-Trevor
Comment #31
ambientdrup CreditAttribution: ambientdrup commentedOne additional note/finding here. This patch did not work until I ran a db update. I checked my status report and the Database update script was showing red. I proceeded to run the db update and it updated the Date module to implement this increment change to "1". So I'd suggest that we add to the patch documentation that a db update is necessary before it actually works.
Also is there any possibility of making this work with the Date pop up widget?
-Trevor
Comment #32
DevElCuy CreditAttribution: DevElCuy commented@ambientdrup, this issue has been resolved and released in version 7.x-2.6, you don't need the patch.
Comment #33
ambientdrup CreditAttribution: ambientdrup commentedOk great. But does this patch only fix the text field? Does it also allow for minute incrementing using the pop up calendar widget? I still cannot get that to work using the patch.
-Trevor
Comment #34
ambientdrup CreditAttribution: ambientdrup commentedI can confirm the patch and update to 2.6 works and solves the increment issue. Just make sure to also configure the date field to use 1 min increments (under advanced config tab on the field).
Best-
Trevor
Comment #35
arlinsandbulte CreditAttribution: arlinsandbulte commented@ambientdrup
what are your date field granularity settings?
I think it defaults to 15min granularity, which it looks like you are seeing.
Comment #36
ambientdrup CreditAttribution: ambientdrup commentedYep you're absolutely right! I noticed that and changed it to 1 min.
It's working now! Awesome.
-Trevor
Comment #37
MD3 CreditAttribution: MD3 commentedI'm fearing reopening this, but I am experiencing the exact same issue.
Date 7.x-2.6
Drupal 7.24
ECK 7.x-2.0-rc2
Created a custom entity only to find the exact same issue as previously listed above: no way to change the default increment except to change the widget type. Why is the text field rounding? That's a pretty exact form of entry that one is entering.
Comment #38
MD3 CreditAttribution: MD3 commentedI need to write a patch, but the issue is line 295 in date.field.inc where it uses the default settings.
Comment #39
frobA work around for this issue is to set the date field to use select lists and then you will be able to change the date rounding options. After you set the increment back to 1 then you will be able to change it back to text field.
Comment #40
barraponto CreditAttribution: barraponto commentedThis should fix it for good.
Comment #42
DevElCuy CreditAttribution: DevElCuy commentedGreat work!
Comment #43
rooby CreditAttribution: rooby commentedI assume those test failures will need to be fixed.
Comment #44
rooby CreditAttribution: rooby commentedIt's also worth noting that while this fixes the problem for fields created after this patch is applied, it doesn't fix ones that were created before that and are still at the 15 minute increment.
If we want to fix those we should do another update function like the one in #23.
Comment #47
Romash CreditAttribution: Romash commentedPlease review.
Comment #49
andreyks CreditAttribution: andreyks commentedComment #52
katannshaw CreditAttribution: katannshaw commented@frob: Thank you. Your workaround on #39 worked for me.
Comment #53
marcvangendI ran into the same problem. Since my field definitions were already exported to features, it was very easy to look up the date field instance in the .features.field_instance.inc file, change the line
'increment' => 15,
to'increment' => 1,
and to a feature revert. While this is a pretty easy workaround, we still need a proper fix.Comment #54
kevinus CreditAttribution: kevinus commentedI found same advanced setting for "Time increments" with next steps: 1, 5, 10, 15, 30 (default is 15). You searched this setting?
Comment #55
marcvangend@kevinus: You have chosen the "popup calendar" widget. In that case the time increment is visible on the form. This issue is about the "textfield" widget. If you choose the textfield widget, the time increment setting disappears from the settings form, but the setting itself remains stored in the database and starts messing with your form input.
Comment #56
jgullstr CreditAttribution: jgullstr commentedThe commits listed in #24 would've solved this, but the default increment for date_text fields is put at the wrong level in the widget info array. Attached patch should put the setting in its right place, and update existing instances to an increment of 1 minute.
Comment #57
NancyDru#56 works for me.
Comment #58
Ronino CreditAttribution: Ronino as a volunteer commented#56 works great, thanks!
Comment #59
NancyDruComment #60
jiv_e CreditAttribution: jiv_e at LilDrop Consulting commentedPatch #56 fixes the issue. I haven't tested for regressions.
Comment #62
podarok#56 merged. Thanks
Comment #64
aviddv1 CreditAttribution: aviddv1 commentedI was able to solve this issue by temporarily changing to the Calendar Widget, adjusting the increment to 1 Minute, then changing back to a Text Field.