Closed (duplicate)
Project:
Date
Version:
6.x-2.6
Component:
Date CCK Field
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Dec 2009 at 19:09 UTC
Updated:
16 Sep 2010 at 20:22 UTC
Hi, I've got my custom content type created, and for the From date, I really want to set the default as a specific time (using today's date is fine, but I'd like the time to be, say, 6:30pm). It looks like strtotime should do this, but the help field on the default box says it needs to be relative to today's date/time, which in my case doesn't seem to apply (I've tried passing various values, such as "2010-01-01 6:30pm", and even just 6:30pm, and a few others). Is there a way to accomplish this?
Comments
Comment #1
mrthumpz commentedI ran into the same wall when attempting to set the date field default to a semi-absolute. In my case I needed the last day of February in the current month. In strtotime, using "march 0" works for my case, always returning the last day of February for the current year. This would not work in the relative field, so I left the setting blank, and used hook_form_alter to edit the default for my field manually.
Here is what my code looked like: (replace module with the name of your module, and make sure to use your form id and field name
Comment #2
donquixote commentedThis qualifies as a feature request. I'm missing it!
hook_form_alter() can do the trick, but it's not a very flexible solution. What if I create a new field that should behave the same? What if the field goes into a field group? Etc.
Comment #3
strellman commentedI am trying to figure out how to set the default to 2011-01-22
That seems like it should be easy, but it is all relative.
Maybe there is some way to pull that in from an event node reference.
I don't even see a place to put PHP if I knew how.
Found this http://drupal.org/node/319195
Comment #4
arlinsandbulte commentedDuplicate of #319195: Set default value to a custom strtotime string (for relative or exact dates)