WordPress.org

Forums

Stylish current date (6 posts)

  1. Yolanda
    Member
    Posted 2 years ago #

    I want to get the current date and actually I use

    <?php echo date_i18n('j F Y', time()); ?>
    with a class: <span class="current-date"><?php echo date_i18n('j F Y', time()); ?></span>

    The thing is I want to show it with a background marker and the day bigger than the month. Any idea on how to style it?

    Kind Regards,
    Yolanda.

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

    break it into three 'dates' ?

    <span class="current-date"><span class="current-day"><?php echo date_i18n('j', time()); ?></span><span class="current-month"><?php echo date_i18n('F', time()); ?></span><span class="current-year"><?php echo date_i18n('Y', time()); ?></span></span>
  3. catacaustic
    very awesome
    Posted 2 years ago #

    You'd need to break the date into seperate parts and wrap the parts in new tags that you can style. Something like...

    <span class="current-date">
        <span class="current-date-day"><?php echo date_i18n('j', time()); ?></span>
        <span class="current-date-month"><?php echo date_i18n('F', time()); ?></span>
        <span class="current-date-year"><?php echo date_i18n('Y', time()); ?></span>
    </span>
  4. Yolanda
    Member
    Posted 2 years ago #

    Yes! worked!
    and to show the day of the week (name)?I have this for the moment:
    the date with a red marker background: http://diariomenu.com/
    and would need to show the day of the week (monday,etc) and if possible to show the entire background marker over the content, is it a z-index class?

    Kind Regards,
    Yolanda.

  5. catacaustic
    very awesome
    Posted 2 years ago #

    You can find the different formats that are available by looking at PHP's manual page for date(). There's a huge amount of options there so I'm sure that you'll find what you want.

    I'm not 100% sure on what you want to do with the background but it sounds like it's a styling issue. A bit of CSS should be able to get what you want.

  6. Yolanda
    Member
    Posted 2 years ago #

    Thanks catacaustic for the answer to my problem.
    Awesome it worked like a charm!

    Kind Regards,
    Yolanda.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.