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.
This happened when I used the 'Y-m-d h:i a' format.
I can see a working time field, and I can adjust the hours, minutes, and AM/PM without any issues, but when I submit the form, the dates comes out with the time truncated. Specifically, I inserted a drupal_set_message function in the submit op of the nodeapi hook, and that indicated that the date outputted by the form had the time truncated already.
Comment | File | Size | Author |
---|---|---|---|
#3 | date_popup_ampm_bug.tar.gz | 598 bytes | Mike Wacker |
Comments
Comment #1
debrajn CreditAttribution: debrajn commentedyou can print like following
format_date($node->created, 'custom', 'D, d M Y h a')
Comment #2
KarenS CreditAttribution: KarenS commentedI have no idea what this report is saying, either the original report or the reply. Read through the debugging tips on the project page and if you still have problems after that I need an example that I can reproduce, which means telling me exactly how the field is configured, what value you are putting into it, etc.
Comment #3
Mike Wacker CreditAttribution: Mike Wacker commentedAttached is a 20-line module that demonstrates the bug (which I tested this time against version 6.x-2.1). Its pretty easy to read the code and see what it does, but here's the description.
It creates a popup date form item on the node edit form under "Authoring information", and then echoes back the value of that form item when you submit the form. Enter a date and time, and you'll see that the value comes back with the time set to 00:00:00, no matter what you put in as the time.
Comment #4
KarenS CreditAttribution: KarenS commentedYou left several really really important pieces of information out of this report.
1) You are not using CCK to create a Date popup in the normal manner, you are trying to implement a custom element using the API.
2) You are trying to intervene in the node published date field to use the date popup there.
I originally tried to alter the node published date automatically but found that lots of other modules interfere with that field so that there is no reliable way to add the Date Popup to it and have it work right. And in this case the reason 12 hour time won't work is that Drupal Core is making assumptions about what value is in that field and doing it's own manipulation of the value. If you change your format to use 24 hour time (which is what core expects to be in there) it works fine.
This is not a bug, this is something that may or may not be possible to do with the way that core works now.
Comment #5
Mike Wacker CreditAttribution: Mike Wacker commentedThe inference on 2) was incorrect. I'm not trying to override the node published date field; I was adding another date field under the "Authoring information" fieldset when I originally encountered this bug. I can replicate this bug in any form, not just the node edit form. Here's a modified date_popup_ampm_bug.module which demonstrates this:
Comment #6
KarenS CreditAttribution: KarenS commentedOK, I can see what you're talking about now. Wow, no one ever gave me a module to do my debugging before. Kind of nice!
I'll see what I can figure out...
Comment #7
KarenS CreditAttribution: KarenS commentedOK, the problem in your case is you are using a time format that the timepicker widget doesn't support. So you tell the API to expect a date as H:i a but the timepicker is sending a date that looks like H:iA. Since the time is not in the expected format, it can't be interpreted.
This is a limitation of the timepicker and using the API. In the UI I don't let you select a format the timepicker can't use, but I can't keep you from doing that in your custom code.
Someone should add this to the documentation. It is documented in the module code itself, and I guess I assumed anyone writing code might look there. If you have time, you can write a patch to add this to the advanced help documentation.
Comment #9
Umayal CreditAttribution: Umayal commentedhow to save manually AM/PM time format to content.
I already saved manually year,month,day,hour,minute.
(I created the node pro-grammatically)