WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] align today's date on right margin (5 posts)

  1. befree22
    Member
    Posted 1 year ago #

    Could someone help me align the date to the right margin of site

    I added the php code for today's date to the header.php file: http://pastebin.com/7AEQaFNS

    I added this code to the .css file: http://pastebin.com/gb5hnkya

    What am I doing wrong?

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    the_time() does show the publish time of a post;
    outside the loop, this could be random, possibly the last or first post on the page.

    http://codex.wordpress.org/Function_Reference/the_time

    consider to use date() instead; http://php.net/manual/en/function.date.php

    as for the formatting, you are confusing css ids and classes;
    http://www.w3schools.com/css/

  3. befree22
    Member
    Posted 1 year ago #

    OK, I used this code for the date: <?php echo date('l jS, F, Y') ?>

    For the css, I added this code but the date isn't aligning to the right of the blog page:
    `.todaysdate {
    float: right;
    color: #444;
    font-size: 20px;
    line-height: 1.625em;
    padding: 0 1.2125em;
    margin-top: 10px;
    font-weight: bold;
    }`

    It works when I use .todaysdate but not when I use #todaysdate. Thanks :)

    I'm using a 2012 child theme on the site.

  4. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    You need to use .todaysdate (period for class, hashtags are for id)

  5. befree22
    Member
    Posted 1 year ago #

    It works! Now I know the difference between period for class, hashtags are for id.

Topic Closed

This topic has been closed to new replies.

About this Topic