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.
Is it possible to theme Start Time and End Time? I would like to display the date and time in a different format.
Thanks
Comments
Comment #1
thomasmurphy CreditAttribution: thomasmurphy commentedsubscribing
Comment #2
phil88 CreditAttribution: phil88 commentedI found a solution for this. I created a node-event.tpl.php and commented out the $content variable. Then I worked with the end time and start time variables included in the $node object directly.
$node->end_time_format
$node->start_time_format
Comment #3
thomasmurphy CreditAttribution: thomasmurphy commentedThat sounds internesting. Could you post what you had in node-event.tpl.php instead of $content?
Comment #4
phil88 CreditAttribution: phil88 commentedI have printed out the variables; here are some:
$node->event_start
$node->event_end
This will show you the entire event node object in node-event.tpl.php
print_r($node);
If you have locations module, you can also display the location with
print_r($node->locations[0]);
Comment #5
yassubscribing
Comment #6
lonehorseend CreditAttribution: lonehorseend commentedYou have to write a template override in your template.php for the theme_event_nodeapi function.
The reason it says "large" instead of "long" is that in Drupal 5.7 (and possibly other versions), the admin date and time labels do not match the format_date function.
The equavilent is:
Short (admin) -> Small (format_date)
Medium (admin) -> Medium (format_date)
Long (admin) -> Large (format_date).
This bug was reported for Drupal 6rc4 as well - http://drupal.org/node/221006
For all the things you can theme in event, look in the event.theme file in the event module directory.
Comment #7
Slim Pickens CreditAttribution: Slim Pickens commentedThis has been driving me nuts for a while now.
I tried the method above and it returns Jan 01 1970.
Stripping it back, I've tried all manner of event node variables in this kind of thing:
and all I get is the appropriately formatted Jan 01, 1970.
I'm presuming the actual date is being fed in to the theme code from somewhere else. I see that $node->event['start_format'] is actually being declared in the event.module and doesn't seem amenable to theming.
It would be really great to be able to easily cutomise the date display in theme. I'm trying to use this module on a couple of sites and from my perspective, Year is never needed, and for a gig, for eg, I need something like: Fri May 30 - 8.30pm, but it seems difficult to actually get this.
Any other suggestions?
Comment #8
hargobindTwo things are wrong with your code:
$node->event['start']
needs to be$node->event_start
And as mentioned in the post above, use
'large'
for the second perameter....and don't forget the offsets.
It would be wise to just copy/paste directly from the post above and just change the date formats like this:
Comment #9
lonehorseend CreditAttribution: lonehorseend commentedAlso, my code in post 6 is dependent on whatever you have set in the admin panel for your large, medium, and small date formats.
Comment #10
Slim Pickens CreditAttribution: Slim Pickens commentedI've revisited this today wondering if anything had changed with the latest D6 event module, and sadly no.
I've added a start date to the theme function in template.php.
The following code works as expected: Days until the event is displayed in the block, and the start date is shown correctly in full - year, month, day, hours, minutes.
When I wrap $node->event_start in any kind of date format the start date is displayed as (Jan 1 1970 - 10:33am). For eg.
Does anyone know why $format_date should change $node->event_start from the correct input time to 1970?
Comment #11
NiklasBr CreditAttribution: NiklasBr commentedI have not succeeded in making this work either so I am subscribing to this issue.
Comment #12
hm2k CreditAttribution: hm2k commentedI too am having trouble changing the date format from the short to medium, long or otherwise.
Moving priority to major as it has been an open issue for so long.
Comment #13
stevegmag CreditAttribution: stevegmag commentedI was able to get it working by adding the following to the template.php file in my theme: (Drupal 6.19)
Comment #14
jackfoust CreditAttribution: jackfoust commented#13 worked for me, thanks Steve!
Comment #15
jackfoust CreditAttribution: jackfoust commented#13 does not support DST. Had to revert those changes =(
Comment #16
japerryEvent for Drupal 8 is unrelated to older versions. If an issue similar to this one exists, please open a new issue with the 8.x branch.