bookout’s picture

I would also like to see this for Drupal 6. I'd be happy to help with testing.

capellic’s picture

I just tried to run CCK Time through Deadwood ( I was able to add the Field to my content type as text/Date. But then when I went to add a new node of that content type, the field wasn't thre.

Gerald Mengisen’s picture


YesCT’s picture

I'm in need of this too

tyromind’s picture

I had submitted a feature request on the Date project for this function. I don't know what's involved with porting over but is there a possibility?

Date feature request:

steve.m’s picture

Assigned:Unassigned» steve.m

Hey all. We are now testing a D6 version of this module. I'd like to see it released within the week.

tyromind’s picture

Awesome! Need help testing?

jesss’s picture

Has there been any progress on this?

cyberskier’s picture


tyromind’s picture

This feature's also being discussed at #219794: Allow dates without years. on the Date Module. Mostly looking to this module being ported, and hoping it could support timezones from the date module - so everyone could see the time displayed in they're own timezone

aqua_linksunten’s picture

would be cool to see this module for d6!

Witch’s picture


bluecobalt’s picture

Hey steve.m, any word on this? Do you have a version for testing? How far are you on this? Need help?

greenbeans’s picture

Status:Active» Needs work
new8.95 KB

I've made a very preliminary D6 port -- hasn't been rigorously tested, but sort of works under the circumstances I need it for.

corpx’s picture

thanks for the initial port. here's a fatal error that I ran into when attempting to add a cck time field to a content type.
Fatal error: Maximum execution time of 30 seconds exceeded in /home/xxx/sites/all/modules/cck_time/cck_time.module on line 189

greenbeans’s picture

CorpX, that looks like an issue with your server configuration and the fact that Drupal's not exactly a lightweight framework -- not specific to this module.

steve.m’s picture

I just grabbed greenbeans' port, and will check it out ASAP.

corpx’s picture

Thx for the feed back. I'll look into server logs. I'm testing a new site and doing so on a virtual server. I guess it has its limitations. thx.

pschopf’s picture

Can we think about a database storage in seconds (0 - 86400), then the time field would be sortable.

It is relatively easy to convert to/from h:m:s to seconds ($value is here the number of seconds):

  $clock     = isset($field['format']) ? (int) $field['format'] : 24;
  $minute = (int) ($value % 3600 ) / 60;
  $second = ($value % 60);
  $hour = (int) ($value/3600) % 24;
  if ($clock == 12) {
    $ampm = $hour < 12 ? 'am' : 'pm';
    $hour = ($hour+11)%12+1;
    $output = sprintf('%2u:%2u:%2u%s',$hour,$minute,$second$ampm);
    $output = sprintf('%2u:%2u:%2u%s',$hour,$minute,$second);

  $value = ($hour % 12)*3600 + $minute*60 + $second;
  if ($clock == 12 && $ampm == 'pm') {
    $value += 43200;

In the above, I am anticipating adding an 'to time...' field that might cause you to want to have "next day" appended, such as you see when a scheduled airline flight takes off at 11:00pm and arrives at 1:00am (next day). The flight takes off every day, so the date is not relevant, but the "next day" concept is.

  $day = (int) $value/86400;
  switch $day {
    case 0:
    case 1:
      $nextday=t(' (next day)');
      $nextday=' ('.$day.t('days later)');
  $output .= $nextday;

At first, I was opposed to including Timezone information because that would introduce date information, but my airline example leads me to want to add timezone information someday - the plane lands 3000km away, can the end of the time interval be expressed in the local time at the destination??? (Someday)

greenbeans’s picture

pschopf -- that sounds like a great idea. Do you want to implement it? I just don't have time (er, pun unintended) at the moment. I agree that the current storage is clunky. Although simply always storing a 24-hr clock value would also be sortable. We'd just have to add a DB field to indicate how the number should be edited / displayed. Your call; storage should be transparent to the end-user anyway.

steve.m’s picture

If anyone working on D6 code here has a CVS account, drop me a line, and I'll add you as a maintainer of this module.

Gerald Mengisen’s picture

pschopf: nice idea, but what would be the migration path for existing nodes where the time is saved as text? Maybe a mass-update action?

greenbeans’s picture

new20.13 KB

Tracked down the problem CorpX was having -- uninitialized values were causing the module to get stuck in an infinite loop. Here's a corrected version.

corpx’s picture

Sweet! thx greenbeans! I'll test it early next week and report back.


pschopf’s picture

@greenbeans: I have done a personal "time_of_day" module so as to avoid confusion, and have learned a lot about the inner workings of cck with dprint_r(array('line'=>__LINE__,'file'=>__FILE__,'fieldxxx'=>$fieldxxx));
all over the code. I have set up 3 "clock formats" 0=>'seconds', 12=>'12 hour clock', 24=>'24 hour clock', which seem to work, and to be recognized when adding the field to a cck node type.

I am now having trouble intercepting the 'save' and 'update' operations to translate from 12 or 24 hour clock to seconds before inserting into the database. Would you like to look it over?

greenbeans’s picture

@pschopf -- I'm in a launch crunch right now, might be a few weeks till I could get to it. I might not be your best bet anyway. I don't really grok the CCK API yet, and kind of felt this one out by trial and error. Actually, you could probably look through the CCK Time code to figure out how it's done. There are some manipulations in there pre-save to convert the three form fields into one DB field.

pzero’s picture


Is there any plan to make an official CCK Time build for Drupal 6?


pschopf’s picture

@greenbeans: I guess we are at about the same stage. I will continue on. If it gets working, it can be merged into CCK Time if we want.

If anyone want to tell me how to take output from a textfield widget (12:00pm) and get it stored as 43200, jump in. I can do the calculation, it is just knowing all the new CCK "field_instance" stuff.

tregismoreira’s picture


I installed the module, and apparently is working perfectly, except for the following facts:

- Even if I select the 24-hour format, the AM-PM field appears.
- Below the fields of time, is written Array. I think you missed something in the programming of the module, but I do not identify.

How could I do to solve these problems?

Grateful in advance!

greenbeans’s picture

Sorry, I don't have any time right now to fix those problems, but if you know any PHP, you should be able to dig into the code and find the solutions.

Maybe pschopf's version, once complete, will be a little more polished.

muhleder’s picture

Had to change the theme function to get double zeros for on the hour times eg 1:00PM

* Theme function for 'default' text field formatter.
function theme_cck_time_formatter_default($element) {
  $hour = $element['#item']['hour'];
  $minute = sprintf("%02d", $element['#item']['minute']);
  $meridien = $element['#item']['meridien'];
  $output = $hour . ':' . $minute . $meridien;
  return $output;

You might want to add leading zeros to the hour too if you're in 24hour mode.

ianchan’s picture


Gerald Mengisen’s picture

Tried out the file from comment #23 today, got the same problems as #29 plus the problem that in edit mode, the hours, minutes and am/pm combobox are shown stacked vertically underneath each other instead of next to each other in the Garland theme.

Nevertheless, thanks for the work done and I hope I can contribute some solutions soon (have never dealt with CCK fields before, however...).

Gerald Mengisen’s picture

About the vertically stacked comboboxes:
The D5 version had one div more:
<div class="cck-time-element"\>

before the <div id='edit...' class="form-item">

With that div, the comboboxes are probably going to show up OK since the "cck-time-element" class floats left.

Beats me at the moment where in the code to add that div....

Gerald Mengisen’s picture

Status:Needs work» Needs review
new9.95 KB

Here is now a version based on greenbean's work at comment #23 (thanks very much!). The following changes have been implemented:

  • Maximum backwards compatibility to the D5 version. That means that the time gets stored exactly the same way as before as one single text field and AM/PM times without leading zero and no space between the time and AM/PM, and yes, sorry, this is not sortable if you use AM/PM notation. Greenbean's version stored the field in 3 database fields.
  • Added prefix/suffix to the fields and the style sheet in order to display the fields in one line horizontally
  • Found that the 'Array' printing came from the 'theme_fieldset' function in; actually, it is due to the fact that $element['#value'] is set with $element['#value']['hour] and $element['#value']['minute']. This lead to the hack on line 272 in cck_time.module to remove that element. I'd be grateful if somebody found a more elegant solution.
  • I have no idea what the correct code should be for theme_cck_time; I took so far a declaration I found for another CCK field type. If somebody has a better idea -great! In fact, the problem with the 'Array' printing might be linked to this.
  • The field configuration screen no longer allows to define multiple values for this field type.
  • Updated the code according to the standards check in coder module

On a side note, it seems that OpenConcept (where the original maintainer of this module works) had ported the module internally to D6 already by the end of last year:
It is unfortunate that they did not choose to publish their results for whatever reason. I did ask them a few weeks back if they would share the module, but unfortunately, I never got a reply.

anthonym’s picture

Thanks for this. Just tried it out. I have two time fields for start and end times. I originally had them checked as required, but when I tried to save the node, I got a message that the fields were required, and it wouldn't save. I went back and unchecked required, and then it worked.

ianchan’s picture

new9.64 KB

I tired the files from #35 but it didn't work. It only seemed to save the default values.

Working off the .module file in #35 and using some of the other CCK modules as reference, I was able to come up with something that almost works. However, I can't figure out how to merge the fields. Or maybe they are merging BUT right now all that is saving to the database is the first numeral.

So for example, when I save 12:00PM, only "1" is saved to the database! If I save 8:00AM, only "8" is saved, etc. Any ideas, tips? Thanks in advance...

The attached is what I've come up with thus far.

Gerald Mengisen’s picture

Some ideas to check:
- What is the data type of your time field in the database? varchar(1) could lead to the problems you describe.

- Do you see the problem with existing CCK time fields or did you also to create new ones?

EgorfromMurmansk’s picture


kenorb’s picture

Assigned:steve.m» Unassigned
new10.15 KB
new451 bytes

Fixed issue with field required on submission.

fallsemo’s picture


#40 patch works - except that now it doesn't seem to store more than one group when using the new "Multi group" feature in CCK 3
Not to complicate things but it is where CCK is heading and it WAS working before.

kenorb’s picture

So how it was working before if it was not possible to even submit the form?

fallsemo’s picture


I had no problem submitting the form before using #35

The problems previously for me had been:

1. Values submitted as X:00 would appear (and store) as X:0
2. Default values would not store properly. In my case, I had set a default to be 2:30PM and it would show up on the form as 2:30AM
But yeah, if I changed this value on the form and hit submit it would show up (and store) the value just fine.

Your patch seemed to resolve both of these issues for me.

Gerald Mengisen’s picture

Strange, I've been using the version from comment #35 ever since without the problems posted above. Maybe because I'm using 24h time formation?

One warning however: when I recalculated the auto node titles from the content menu, all CCK Time values were lost. Maybe this wouldn't be the case with the later patches. And yes, +1 for the Backup and Migrate module :-)

bomarmonk’s picture

Yes, I definitely need the issue mentioned in #41 to be resolved for implementation of this module with multigroups (for the same use-case scenario illustrated in fallsemo's images-- office hours). Is multigroup and CCK time working for you now, fallsemo? Let me know. Thanks.

fallsemo’s picture

Its not. I ended up scratching it and doing something else :(
I can help test if a patch rolls in.

rcharamella’s picture

How do you "install" this time field?

a_L_p’s picture

I have successfully installed the module from #35, and I can add a new time field to a content type. However, I have two fields (field_begins & field_ends) that I created with the 5.x version of the module and the content associated with those fields is not showing up when I add the fields to a view.

Here are some inconsistencies I am noticing when comparing the database entries:

The new time field I created shows the type and widget as "cck_time" While my old fields show the type and widget as "text"
The old fields also have no value for the column "db_colums" while every other field has a value there.

I am guessing that this is a clue to what is going wrong however, working directly with the drupal database is new territory for me. Can anyone advise me on what I can do to remedy this issue?

One other note, when I updated this module and ran update.php there were no updates attempted.


Gerald Mengisen’s picture

Yes, I had the same problem. I had to recreate the view column.

bomarmonk’s picture

For making this work with content multigroup (CCK 3):


All fields that allow the Content module to handle their multiple values should
work here. Fields that handle their own multiple values will not be allowed
into Multigroups unless they implement hook_content_multigroup_allowed_widgets()
to add their widgets to the allowed widget list. Example:

  function MODULE_content_multigroup_allowed_widgets() {
    return array('WIDGET_NAME_1', 'WIDGET_NAME_2', ...);

All fields that allow the Content module to handle their multiple values
should work correctly when a field placed on a Multigroup is moved off, to a
normal field group, or to the top level of the form. Fields that handle their
own multiple values which may store different results in Multigroup and
standard groups should implement hook_content_multigroup_no_remove_widgets()
to add their widgets to the list of widgets that cannot be removed from
Multigroups. Example:

  function MODULE_content_multigroup_no_remove_widgets() {
    return array('WIDGET_NAME_1', 'WIDGET_NAME_2', ...);

The Content Taxonomy module [1] is an example where it implements the previous
hooks for a few widgets.

quicksketch’s picture

new3.27 KB

I took the Zip from #40 and ported it to a new module called "timefield". It's the same thing only it stores the data differently. I didn't like storing the data as text since you can't sort on the data. In addition you can't change from 12 to 24 hour formats after the field has been set up (well you can but the data isn't migrated).

This version also works with multiple values and handles requireness correctly. However it does not upgrade data from the old cck_time format to timefield. I'd be really happy to see this become a separate project, but I do not have the availability to support more modules at this time. It'd probably be good to move away from the name "CCK" regardless, since it's been renamed to "Field" in Drupal 7.

bomarmonk’s picture

Testing Quick Sketch's latest version of this module in #51; it's working great with multigroup. How about an official release of the development version? This is good stuff! Thanks for your work on this, sketch.

GlossyIbis’s picture


ronincreative’s picture


bomarmonk’s picture

Quicksketch, I vote that your module in #51 gets turned into a new project: Time Field. Can someone maintain this? Any takers? I can apply patches, but have never worked with CVS. There's also an issue over at the Date module that's related to this. I'll see if I can't get any interest drummed-up over there. Thanks again for your work on this!

joshmiller’s picture

Yay for monolithic issue ques with ENTIRE modules in them.

No, seriously, thank you for this timefield module from #51.

We are using it extensively on a new site. Below is a bug one of our programmers is actively dealing with and trying to fix. I will keep you up to date. This bug is only encountered when trying to sort multiple times in Views.

Small bug noticed in the new `time' field. It thinks that 12:01AM to 12:59AM comes between 11:59AM and 1:00PM. I can understand how this could happen programatically, but it does pose a problem when a "lunch" is entered at 12:30PM, it shows up at the end of the session list, instead of in the middle where it should be. If you set the time to 12:30AM, it shows up in the middle.

kenorb’s picture

Status:Needs review» Reviewed & tested by the community
Junro’s picture


I'm testing Time cck submodule.

1. The name widget in /admin/content/node-type/*/fields shouldn't be Date. I think "Time" will be more appropriate because Date widget already exists.

2. How to customize the time format?

We can choose only between 12 & 24 format with a only display: 12:23.

I would like to have something like this: 12 hrs 23 min or 12h23.

dml’s picture

I've also been using the timefield module from #51, and I'm very happy with it.

There's one small issue where if you enter 12:30pm it shows up as 12:30am (either that, or I've forgotten how a 12hr analog clock works, which is entirely possible). I think a change along the following lines to the timefield_time function should fix that.

  // Edit 2010-03-30
  $time['meridiem'] = $time['24hour'] < 12 ? 'am' : 'pm';
  if(($time['12hour'] = $time['24hour']%12) == 0){
    $time['12hour'] = 12;
  // commented out: check what happens when $time['24hour']==12
  if ($time['24hour'] > 12) {
    $time['12hour'] = $time['24hour'] - 12;
    $time['meridiem'] = 'pm';
  elseif ($time['24hour'] == 0) {
    $time['12hour'] = 12;
    $time['meridiem'] = 'am';
  else {
    $time['12hour'] = $time['24hour'];
    $time['meridiem'] = 'am';
GlossyIbis’s picture

@quicksketch thanks very much for this. It works a treat.

I actually don't like the UI for datetime: the time UI element is very poor compared to the terrific popup calendar on the date part. So I have combined your time module with the date part of the datetime - in a rather amateurish clumsy way (because I don't know enough to do it property and nor do I have the time to learn). I have two "disposable" fields - date and your time - for the UI, and I use a rule to combine the two values together into another datetime value. It works much better. UE/UI is crucial for us.

It would be good if someone had the knowledge and time to integrate the two properly. At least make time a "proper project...?

Cyberwolf’s picture


bomarmonk’s picture

@GlossyIbis, have you seen this patch for time input with the date module. It adds a time insert for time fields associated with the date module. Maybe the same code can be used for the CCK time field:

kenorb’s picture

Version:6.x-1.x-dev» 5.x-1.x-dev

Committed version from #40

Any further patches are welcome.

kenorb’s picture

Version:5.x-1.x-dev» 6.x-1.x-dev
Status:Reviewed & tested by the community» Fixed
rwd’s picture

Patched the D6 port to accept empty values if the field is not required, awaiting review at #766832: Accept empty values if CCK Time field not required.

Cyberwolf’s picture

Using the timefield contribution from #51 here as well, great job @quicksketch!
How do the committed changes (#63) to CCK Time compare to timefield?

kenorb’s picture

Version:5.x-1.x-dev» 6.x-1.x-dev


Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

drecute’s picture

Will be starting up support for views integration for this module.

mansspams’s picture

lol. subsr.

Roze’s picture

Subscribing !

doublejosh’s picture

Tested today on a D6 site. Works great.