Displaying Date Using PhP in wordpress

Discussion in 'PHP' started by Hades, Dec 26, 2007.

  1. #1
    I am building a theme, and I am trying to make it so that it displays a date in a certain way (see image), but Im not sure how to do it. I went to the php date library thing, but there is no lower case 3 letter months. How can I accomplish this?

    This is the php code for date in wordpress
     <?php the_date(); ?>
    PHP:

    Thanks
    Nick
     

    Attached Files:

    • date.gif
      date.gif
      File size:
      270 bytes
      Views:
      84
    Hades, Dec 26, 2007 IP
  2. hogan_h

    hogan_h Peon

    Messages:
    199
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't use WP, but in php you can display 3 letter months using "M" as formatting.
    <?php echo date("M"); ?>
    To get it to lower case you could use built in strtolower funktion:
    <?php echo strtolower(date("M")); ?>

    Does this help or is it totally diferent in WP?
     
    hogan_h, Dec 26, 2007 IP
  3. Hades

    Hades Well-Known Member

    Messages:
    1,873
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    150
    #3
    well, I was using the M thing, and this is what I had

    <span class="post-month"><?php the_time('M') ?></span>
     <span class="post-day"><?php the_time('d') ?></span>
    PHP:
    It displays it the way i needed it to display, but it just has Dec capitalized. Am I allowed to put <?php ?> in side of <?php ?>

    Like if I do

    <span class="post-month"><?php the_time('<?php echo strtolower(date("M")); ?>') ?></span>
     <span class="post-day"><?php the_time('d') ?></span>
    PHP:
    would that work?
     
    Hades, Dec 26, 2007 IP
  4. hogan_h

    hogan_h Peon

    Messages:
    199
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I don't think that nesting another php tag inside would work. I would need to take a look at the_time() WP function to see what it does... I will reply here soon if i find anything...
     
    hogan_h, Dec 26, 2007 IP
  5. Hades

    Hades Well-Known Member

    Messages:
    1,873
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    150
    #5
    ok, thank you very much.
     
    Hades, Dec 26, 2007 IP
  6. hogan_h

    hogan_h Peon

    Messages:
    199
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Try wrapping a strtolower call around the_time function, something along this lines:
    <?php echo strtolower(the_time("M")); ?>
    Try it with and without echo. The only problem would be if the the_time() echoes its output directly.

    http://wordpress.org/support/topic/135690
     
    hogan_h, Dec 26, 2007 IP
    Hades likes this.
  7. Hades

    Hades Well-Known Member

    Messages:
    1,873
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    150
    #7
    That didn't work. Thanks for trying though. I just figured out how to do it. I used css and style post-month to have text-transform:lowercase; and it worked.

    Thanks a lot for your help.
    Nick
     
    Hades, Dec 26, 2007 IP
    hogan_h likes this.