Date in PHP

Discussion in 'PHP' started by admin3633, Mar 29, 2009.

  1. #1
    This is a simple yet great tutorial on how to display the date in PHP.

    Here is the code snippet:

    <?php
    echo strftime('%d %B %Y',time());
    ?>

    This will result something like: 01 January 2009
     
    admin3633, Mar 29, 2009 IP
  2. kusal

    kusal Peon

    Messages:
    91
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can do that like this also

    <?php
    echo date("d F Y");
    ?>
    Code (markup):
     
    kusal, Mar 29, 2009 IP
    pipes likes this.
  3. sajanParikh

    sajanParikh Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah, I think the date() function is more commonly used.
     
    sajanParikh, Mar 30, 2009 IP
  4. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #4
    echo data("m/d/y"); // 25/02/09
    echo date("m/d/y",time()); // 05/02/09 14:38:12
    PHP:
     
    ActiveFrost, Mar 30, 2009 IP
  5. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    This is the simplest example of using the function... Reading the php documentation for date() will give you a lot more knowledge and understanding why it does what it does, how to use it in different situations, etc, etc.
     
    xlcho, Mar 30, 2009 IP