Changing Date format and put it into a div or span
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.
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.
-
- Joomla! Apprentice
- Posts: 16
- Joined: Sat Apr 17, 2010 2:22 pm
Changing Date format and put it into a div or span
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?
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?
- gyroglm
- 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
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.
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.
-
- Joomla! Apprentice
- Posts: 16
- Joined: Sat Apr 17, 2010 2:22 pm
Re: Changing Date format and put it into a div or span
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")
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")
-
- Joomla! Apprentice
- Posts: 16
- Joined: Sat Apr 17, 2010 2:22 pm
Re: Changing Date format and put it into a div or span
Sorry but I dont get it :/
- gyroglm
- 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
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?
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?
- ant
- 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
I think that was the point from ray2mi and it is for sure what I was looking forgyroglm wrote:Or am I missing the point?
Thank you
-
- Joomla! Intern
- Posts: 64
- Joined: Mon Feb 04, 2008 10:43 pm
Re: Changing Date format and put it into a div or span
If you change this here:
Into this here:
And in the css file you can use
To style the day and month individually.
Code: Select all
<?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON', JHtml::_('date', $this->item->created, JText::_('DATE_FORMAT_LC2'))); ?>
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>
Code: Select all
.date{}
h5.day{}
h5.month{}
- ant
- 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
Great! This seems to be a little more elegant solution
Thank you!
Thank you!