I had an issue in which scheduler was always saving my dates at midnight (00:00). I traced this to be an input format related problem.
The first input format I used was: "m/d/Y h:i a" and executing this code would always return midnight:
$node = node_load(arg(1));
print format_date($node->publish_on);
When I switched the format to "m/d/Y H:i", the module began behaving correctly.
(Using date popup).
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | date-642018-6.patch | 544 bytes | slip |
| #6 | scheduler-642018-6.patch | 4.39 KB | slip |
Comments
Comment #1
kmontyTo be clear, this was the format on admin/settings/scheduler
Comment #2
eric-alexander schaefer commentedI checked it and you are right. Date popup does not handle the format correctly. E.g. it uses AM and PM if 'a' is configured (should be 'a' => am+pm, 'A' => AM+PM). It does not use the configured space between the minute and AM/PM. Either because of these two problems or for another reason it returns 0 minutes and 0 hours (=> midnight).
I will not bother filing an issue since the last issue I filed for the date popup module did not even receive an answer. I will just extend the format description at admin/settings/scheduler...
Thanks for reporting, but I am afraid you will have to live with H:i.
Comment #3
eric-alexander schaefer commentedhttp://drupal.org/cvs?commit=295048
Comment #4
kmontyThanks Eric. I am moving this to the date popup issue queue since it is definitely a bug that should be looked at.
Comment #5
slip commentedThe date format setting at admin/settings/scheduler seems to need to be set perfectly to work with date_popup.
Works:
Y-m-d h:i:sA
Doesn't work:
Y-m-d h:i:s A
That one space seems to cause all sorts of problems, which seems a little crazy. If anybody wants to verify that'd be nice, but I definitely just had to remove the space and everything works... So if this is true the help text commit in #3 should be modified and maybe the date module needs to be a little more flexible or scheduler needs to do something different.
Got the idea from:
Comment #6
slip commentedSo I've attached a patch that removes spaces from time formats so date.module reads them correctly. This would make a nice addition to date_popup.module in my opinion and it would help people avoid the pain I've experienced with the scheduler module :)
I've also included a rough patch to scheduler which makes it force valid time formats based on date_popup_time_formats() (but I need to know if this function actually exists to return the only possible valid formats which the calendar recognizes). This patch also allows the user to not use Date Popup with scheduler if both are enabled, which is another feature I think it'd be nice to have.
Comment #7
slip commentedComment #8
karens commentedClose, but not quite right. Wiping out all spaces breaks things if you have spaces elsewhere in the date format. I committed a modified patch. Thanks!
Comment #9
karens commentedYour scheduler patch needs to go in that queue.
Comment #10
slip commentedThanks KarenS! I wasn't sure if I had it quite right so I'm glad you were able to improve it.
FYI: I created an issue for the scheduler module soon after I commented here. That patch was committed a few months ago.