CCK Time Field
trantt - April 6, 2007 - 03:31
I would like to create a CCK Time field (HH:MM), can it be done? If so, can you show me how to go about it?
Thanks
I would like to create a CCK Time field (HH:MM), can it be done? If so, can you show me how to go about it?
Thanks
This may help:
This may help: http://drupal.org/project/date
Date module won't do it
MM DD YYYY are required fields on the date module. In short, I was already tried out this module prior to this post.
if its for something like an
if its for something like an event time, it may be that you can use a few drop downs, one for hours, one for mins (or increments in 15 min blocks of time) and one for am pm.
it would help provoke answers if you explained what your intentions were with such a field?
also searching...
I'm also in need of a cck time field without a date. Trantt's statement is not completely true: the date module does allow a YYYY HH MM field, without month and day. However this is not good enough for me.
I want to display a list of gigs for a band and created a 'gig' content type. One of the fields I'd like to add is a 'doors open' time because this is usually different from the time the gig actually starts.
I also tried the method of creating two select lists (one for the hours 00-23 and one for the minutes 00/15/30/45) but I dont like the way they are placed below eachother in the create content form, it's not user friendly.
Hopefully the date module will make this possible in the future.
Dont have any answer but
Dont have any answer but this is exactly the same thing I am looking for. To figiure out exactly how much time is a user on a page and then come up with a message after a particular time
For example - An user is giving a test/quiz which is to meant to be taken in 15 mins. I would love to have a CCK field which shows how much time the user is on the page and after 15 mins it shows a message (pop up) your time is over.
Time Tracking module
"An user is giving a test/quiz which is to meant to be taken in 15 mins" I have been looking for this modules for several months now but had no luck so far. Please let's me know if you came up with a solution for this.
TIME CCK
I am also looking for a module to handle this.
I need an opening time and closing time for each day of the week for all the gaming centers that sign up for a site I am working on.
No Time Field Available?
This is the same thing with me. I'm creating a movie site, and would like to have a time field to enter the Running Time of each movie, and to help the editors to maintain a standard for entering the time, which is one of my reasons for needing a time field. I thought the date module could do this, but I'm so lost right now.
Can someone help please?
Sig:
Every day begins a new journey...
Opening, closing times
I see this issue is mostly resolved with custom php-like time formats...however, I have a somewhat related question. I want businesses to be able to have opening and closing times...by day. Any suggestions on how to use CCK fields to do this? Other than the most obvious and clunky way, which is to have 7 groups, each consisting of two time fields?
I would suggest this: Have a
I would suggest this:
Have a normal field text field eg.
$form['whatever']['field'] = array(
'#title' => t('Time'),
'#type' => 'value',
'#type' => 'textfield',
'#default_value' => '00:00am',
'#required' => true
);
then validate the field like this:
function formname_validate($form_id, $form_values) {
if (!ereg('(^([0-9]|[0-1][0-9]|[2][0-3]):([0-5][0-9])(\s{0,1})([AM|PM|am|pm]{2,2})$)|(^([0-9]|[1][0-9]|[2][0-3])(\s{0,1})([AM|PM|am|pm]{2,2})$)', $form_values['field'])) {
form_set_error('field',
t('Please Input Your Time In The Correct Format 00:00am.'));
}
May be this will work for you
When you add date field to your content type. There is heading Granularity: just select Hour and Minute. This will display hour and min drop down when you create your content.
There are other options how to display this. Configure those and you are done.
that's not the issue
itahead, the issue is not that a granularity of HH:MM is not available. The point is, that you have to include at least a YYYY field. Sometimes, you just want hours and minutes, without years and months. That is not possible with the date module right now.
its working for me
I added field in my content type as date (Text using strtotime), and later I selected input format / output format as H:i and selected Hour and Min from granularity.
And its working for me.
I agree, that is a possible
I agree, that is a possible workaround. I can see myself using it for sites I am maintaining myself. However I would never deliver this to a paying customer, it would be below my quality standards. (No offense intended, itahead, I don't know in which situation you used it and I'm not judging the fact that you did.)
I would suggest select list
Add a field as date (Select List, ie: the first option usually) and later change the custom output format to H:i.
This will create two select list, one for HOURS and one for MINUTES
regards,
Maozet
www.drupaldir.com
I totally agree
I'm surprised we're forced to add in a date and can't just do time. Seems like a weird limitation and that it could be a simple fix (or is that just wishful thinking)?
cck_time is ur answer
Tadaaaa:
http://drupal.org/project/cck_time
Yay!
Thank you!!
Awesome!
Just what I was after. Shame the Date module doesn't handle this easily. Sounds like the strtotime option will, but it's not ideal. This module is perfect. =)
Office Hours Module
Unfortunately, CCK Time doesn't work with 6.x.
There is also the Office Hours module, which may solve one of the problems here. However, it forces day, opening and closing time so will not be a universal solution.
Dan Blows
Folks, Feel free to use:
Folks, Feel free to use: http://drupal.org/project/duration for your time range needs. :)
Nice work!
Will take a look when I get a chance. Thanks for contributing a well needed module! =)
subscribing
.
Is there a module or solution
Is there a module or solution for 6.x?
Duration module is not what i'm looking for.
Date module will do
Hi folks,
I solved it with the Date-Modul. Just remove or uncomment in the date_admin.inc the validation code for the year granularity
if (!in_array('year', $field['granularity'])) {form_set_error('granularity', t('Granularity must include a year.'));
}
In the Date_6.x-2.3 Version you will find the code in line 238. Works perfectly fine to show just hours and minutes.
I think I just found a solution for this without a hack
This is my 1st drupal.org post... This is assuming that you have the same modules installed as me (Date, etc.), so I make no guarantees, but after you've set up your Date field in your content type (I was making a custom content type with Date, CCK, etc.), set the granularity, etc., create your own custon format and apply it. To do this, do the following:
1) Go to Site Configuration -> Date & Time -> Formats -> Add format
2) In "Format String", enter your custom PHP date code (taken from http://php.net/date - I used g:i A for "9:30 AM", etc.)
3) Go to Configure under the same level of Drupal navigation (under Formats).
4) Either create a new custom format (under Add Format Type at the bottom) and then select your new format from the drop down list, or change one of the existing formats to your new format.
5) Go back to your content type's DateTime field (whatever it is named) and change the Default Display to the format you chose in #4.
This worked like a charm for me, without any module hacks to remove the YYYY, etc.
That's a perfectly good
That's a perfectly good solution on the output side (and similar to http://drupal.org/node/134144#comment-718549, yet better explained) but if I understand correctly, it will not change anything on the node form (input side). This means that the person who enters the node form to create a new node, will still have to select a year when he just wants to enter the opening time. So to me it's only one half of the solution.
Changing the input side is easy
Changing the input side is easy. I fixed that before I came looking for a solution on the output side.
When you configure your date field just create a custom input format.
I used
h i a
for my purposes so that I no longer had to specify a year. However, the year seems to have defaulted to the current year.
That did not fix the display, which still showed the year. That is why I am looking at this suggestion for fixing the output format.
ssg13565
Like you say, a year value is
Like you say, a year value is still stored in the database. That means you still can't perform certain actions with that value, such as sorting values chronologically.
Don't get me wrong, I'm not criticizing the solution that you chose in your specific situation. All methods described in this thread are usable workarounds for certain use cases. My personal itch is that there isn't a generic solution that would always work - but having said that, I must admit that I didn't scratch it myself either.
Works for me
@aubjr_drupal : that was a good workaround. Works for me. Thanks for the tip!
Works for me, too
Thanks for the great tip. This is just what I needed. I now have a separate event date field and a separate event time field. I fixed all my events and all my views.
ssg13565