Notice

The forum is in read only mode.

Support Forum

Welcome! Support Forums have been reactivated
Welcome the Technical Support section. Help us in assisting you by providing us with a concise and descriptive elaboration of your issues. Be specific and if possible, provide us with a step-by-step instruction in replicating your problem.

Custom Time Format

9 years 6 months ago
  • Adam's Avatar
    Topic Author
  • Adam
  • Offline
  • Fresh Boarder
  • Posts: 1
  • Thank you received: 2
Licenses:
JomSocial Active

So it has been really frustrating that there is no simple of changing the event time formatting as the way we view dates in the US is different than the format in Europe/Asia and whenever we do come across a website with a different date/time format, it is a big warning sign that most likely, no matter what the website says, it is not managed her in the US. With that being said, I did find a workaround so in the template overrides, I could actually have the time/date format in the way I want (or anybody for that matter) but I need a function added to the helpers/event.php file so I don't have to keep modifying a core file every time I upgrade. Here is what I've done:

1. In either the layouts/events/list.php or single.php where I want to display the date/time - I used the formatStartDate function like it's used for the large month and day next to the event title. I just modified the format strings as such:
<?php echo CEventHelper::formatStartDate($event, JText::_('M j, Y | g:i a') ); ?>

2. Then I wanted to also display an event end time, however there is no function set for that so in the helpes/event.php file (around line 1477) I added the following function:

static public function formatEndTime($event, $format)

$date = JFactory::getDate( $event->enddate );
$html = $date->format( $format );

return $html;

so then I could do something like this underneath the main event title:
< ? php echo CEventHelper::formatStartDate($event, JText::_('M j, Y | g:i a') ); ? > - < ? php echo CEventHelper::formatEndTime($event, JText::_('g:i a') ); ? >

I know from reading the forum posts, there are a lot of requests to format the event date and time and response from jomsocial is that in order to make it available to change the format, it would require a lot of recoding. At this path doesn't limit us using a date/time format that most Americans are not used to seeing...

Would there be any way that additional function could be added to the next release ?

Thanks,

Adam

9 years 6 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Hi Adam,

To change it you can open language file language/en-GB/en-GB.com_community.ini, and change this configuration value

COM_COMMUNITY_DATE_FORMAT_LC2_24H="%A, %d %B %Y %H:%M"
COM_COMMUNITY_DATE_FORMAT_LC2_12H="%A, %d %B %Y %I:%M %p"

thank you!

Moderators: Piotr Garasiński
Powered by Kunena Forum

Join 180,000 websites creating Amazing communities

JomSocial is the most complete, easy-to-use addon that turns Joomla CMS into a
full -fledged, social networking site

TRY NOW BUY NOW