Changing Date format and put it into a div or span

Everything to do with Joomla! 2.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
ray2mi
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Apr 17, 2010 2:22 pm

Changing Date format and put it into a div or span

Post by ray2mi » Wed Feb 15, 2012 11:08 am

Hi Guys,

I am using the date format LC3 (DATE_FORMAT_LC3="d. F Y") but I want to add some more css to that, therefore I need to put the day into a <span> or a <div> element because I want to apply a different css formation than to the rest.

Does someone know how I can put single elements of the date format into a div or a span?

User avatar
gyroglm
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Sun Jan 29, 2012 10:19 pm
Location: New Zealand

Re: Changing Date format and put it into a div or span

Post by gyroglm » Mon Feb 27, 2012 12:23 pm

Not a div, they're for blocks, spans are for inline elements.
Well, without knowing exactly where you're doing this - just wrap it with <span class="myclass"> ... </span>, then add ".myclass span {what:ever;}" to a stylesheet.

ray2mi
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Apr 17, 2010 2:22 pm

Re: Changing Date format and put it into a div or span

Post by ray2mi » Mon Feb 27, 2012 7:49 pm

Hi,
thank you for your reply.

I wasnt very detailed while explaining the topic. Sorry for that.

I actually want to add a different css to the day, a different css to the month end so forth. But right now it is only possible to format the whole thing since the format is defined like this LC3 (DATE_FORMAT_LC3="d. F Y")

ray2mi
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Apr 17, 2010 2:22 pm

Re: Changing Date format and put it into a div or span

Post by ray2mi » Tue Feb 28, 2012 7:45 am

Sorry but I dont get it :/

User avatar
gyroglm
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Sun Jan 29, 2012 10:19 pm
Location: New Zealand

Re: Changing Date format and put it into a div or span

Post by gyroglm » Tue Feb 28, 2012 11:31 am

I'm not sure where you get this LC3 date thingy from, but if it's with PHP then say
you have a variable $date of the form "29 February 2012" -
use $date_parts = explode(" ", $date);
and then echo "<span class='d'>$date_parts[0]</span><span class='m'> $date_parts[1]</span> <span class='y'> $date_parts[2]</span>";
or instead of class just use individual style=".."

Or am I missing the point?

User avatar
ant
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 158
Joined: Sun Sep 18, 2005 1:22 pm
Location: Italy
Contact:

Re: Changing Date format and put it into a div or span

Post by ant » Wed Oct 24, 2012 1:03 pm

gyroglm wrote:Or am I missing the point?
I think that was the point from ray2mi and it is for sure what I was looking for ;)

Thank you
Ant at Artimediali Web Design
Realizzazione siti web Joomla!
http://www.artimediali.net

Menalto
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Mon Feb 04, 2008 10:43 pm

Re: Changing Date format and put it into a div or span

Post by Menalto » Wed Oct 24, 2012 5:22 pm

If you change this here:

Code: Select all

<?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON', JHtml::_('date', $this->item->created, JText::_('DATE_FORMAT_LC2'))); ?>
Into this here:

Code: Select all

<div class="date">
<h5 class="day"><?php echo JHtml::_('date',$this->item->created, 'd'); ?></h5><h5 class="month"><?php echo JHtml::_('date',$this->item->created, 'M'); ?></h5>
</div>
And in the css file you can use

Code: Select all

.date{}
h5.day{}
h5.month{}
To style the day and month individually.

User avatar
ant
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 158
Joined: Sun Sep 18, 2005 1:22 pm
Location: Italy
Contact:

Re: Changing Date format and put it into a div or span

Post by ant » Thu Oct 25, 2012 10:59 am

Great! This seems to be a little more elegant solution ;)

Thank you!
Ant at Artimediali Web Design
Realizzazione siti web Joomla!
http://www.artimediali.net


Locked

Return to “Templates for Joomla! 2.5”