$date questions

Discussion in 'PHP' started by blackburn2413, Sep 14, 2010.

  1. #1
    Hey everyone. Currently, I have a variable $date that is just numbers in a MMDDYYYY format. I wanted to know if I used 3 dropdowns: one for month day and year if I could combines the 3 results into that one $date variable. Any ideas there?

    The next question is when I want to display this data on my site somewhere, how can I convert say: 09152010 to September 15th, 2010.

    I know these are both possible but need some direction as to where to get started on this.

    Thanks everyone!
     
    blackburn2413, Sep 14, 2010 IP
  2. ven

    ven Member

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #2
    So,
    first you would have to use $_GET or $_POST to get dropdown data, and then for example use it like this:
    
    $date = $_GET['month'].$_GET['day'].$_GET['year'];
    
    Code (markup):
    and for second question,
    you could use http://www.php.net/date_parse_from_format
     
    ven, Sep 14, 2010 IP
  3. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #3
    http://php.net/manual/en/language.operators.string.php

    http://php.net/manual/en/function.strtotime.php

    http://php.net/manual/en/function.date.php

    Follow the examples on the documentation page(s).
     
    danx10, Sep 14, 2010 IP
  4. blackburn2413

    blackburn2413 Member

    Messages:
    45
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    AWESOME replies, I knew how to do the post thing to a variable, but wasn't aware you could combine 3 of them. The other documentation looks great as well. Thanks!
     
    blackburn2413, Sep 14, 2010 IP