Title: Using CSS with the_date()
Last modified: August 18, 2016

---

# Using CSS with the_date()

 *  Resolved [bobdeo](https://wordpress.org/support/users/bobdeo/)
 * (@bobdeo)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/)
 * Hi,
 * I want to separate the result of the_date() to apply different styles to day,
   month and year…
 * Do you know how can I do that ?
 * Thanks in advance

Viewing 13 replies - 1 through 13 (of 13 total)

 *  [yosemite](https://wordpress.org/support/users/yosemite/)
 * (@yosemite)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-430905)
 * [http://codex.wordpress.org/Template_Tags/the_date](http://codex.wordpress.org/Template_Tags/the_date)
 *  Thread Starter [bobdeo](https://wordpress.org/support/users/bobdeo/)
 * (@bobdeo)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-430913)
 * ok thanks… but when I write
 * `<span class="day"><?php the_date('j') ?></span>
    <span class="month"><?php the_date('
   F') ?></span> <span class="year"><?php the_date('Y') ?></span>
 * Only the first one is on the screen…
 *  [yosemite](https://wordpress.org/support/users/yosemite/)
 * (@yosemite)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-430914)
 * From that page:
    `When there are multiple posts on a page published under the
   SAME DAY, the_date() only displays the date for the first post (that is, the 
   first instance of the_date()). To repeat the date for posts published under the
   same day, you should use the Template Tag the_time() with a date-specific format
   string.`
 *  Thread Starter [bobdeo](https://wordpress.org/support/users/bobdeo/)
 * (@bobdeo)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-430918)
 * The date for the first post -> that’s what I want. But I need to split day, month
   and year to apply a style to each (not the same for the 3).
 *  [viper007bond](https://wordpress.org/support/users/viper007bond/)
 * (@viper007bond)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-430924)
 * Well then you’ll need to use `the_time()` or something because as it says, `the_date()`
   only works once.
 *  [yosemite](https://wordpress.org/support/users/yosemite/)
 * (@yosemite)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-430933)
 * e.g.;
    ` the_time('M'); the_time('Y'); the_time('j');
 *  [bronto](https://wordpress.org/support/users/bronto/)
 * (@bronto)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-430957)
 * What about
 * `the_date('<span class="day">j</span> <span class="month">F</span> <span class
   ="year">Y</span>')`
 *  [viper007bond](https://wordpress.org/support/users/viper007bond/)
 * (@viper007bond)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-430965)
 * Yeah, I was gonna suggest that, but I was too lazy to type it out as you need
   to escape a lotta characters in there with backslashes (all the ones that are
   real format characters).
 *  Thread Starter [bobdeo](https://wordpress.org/support/users/bobdeo/)
 * (@bobdeo)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-430966)
 * `the_date('<span class="day">j</span> <span class="month">F</span> <span class
   ="year">Y</span>')`
 * that’s sound good but not working… someone can correct it, I’m a newbie in php
   😉
 *  [viper007bond](https://wordpress.org/support/users/viper007bond/)
 * (@viper007bond)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-430967)
 * As I said, you need to escape all the letters there are codes for stuff.
 * the_date(‘<\sp\a\n \c\l…
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-430970)
 * the_date(‘\<\s\p\a\n \c\l\a\s\s\=\”\d\a\y\”\>j\<\/\s\p\a\n\> \<\s\p\a\n \c\l\
   a\s\s\=\”\m\o\n\t\h\”\>F\<\/\s\p\a\n\> \<\s\p\a\n \c\l\a\s\s\=\”\y\e\a\r\”\>Y\
   <\/\s\p\a\n\>’);
 *  Thread Starter [bobdeo](https://wordpress.org/support/users/bobdeo/)
 * (@bobdeo)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-431000)
 * G-R-E-A-T !
 * Thanks !
 *  [viper007bond](https://wordpress.org/support/users/viper007bond/)
 * (@viper007bond)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-431038)
 * You don’t technically need to escape every single character there, especially
   the `<` and `>`, but oh well. 🙂

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Using CSS with the_date()’ is closed to new replies.

## Tags

 * [the_date](https://wordpress.org/support/topic-tag/the_date/)

 * 13 replies
 * 5 participants
 * Last reply from: [viper007bond](https://wordpress.org/support/users/viper007bond/)
 * Last activity: [19 years, 10 months ago](https://wordpress.org/support/topic/using-css-with-the_date/#post-431038)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
