SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: php date

  1. #1
    SitePoint Enthusiast poil11's Avatar
    Join Date
    Aug 2000
    Location
    it look me along time to do that...
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i am puting the months in numeric format into the mysql table. does php have a command where i can just do date("month","4"); so it will return the value April?
    I will Tell you what is wrong with your website and maybe what you can do to make it better.
    Professional Web Site Reviews ... Usability ...
    Contact Me god@stillsucks.com for more information ...
    look at my other reviews, to see what i have done.

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Probbaly the easiest thing to do is, make an array out of the months with there month numbers as keys:

    PHP Code:
    $months = array(=> "Jan",
                     
    => "Feb",
                    
    => "Mar",
                    
    => "Apr"
                    
    => "May",
                    
    => "Jun",
                    
    => "Jul",
                    
    => "Aug",
                    
    => "Sep",
                    
    10 => "Oct",
                    
    11 => "Nov",
                    
    12 => "Dec"
                    
    );
    //Prints Apr
    print $months[4]; 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Enthusiast poil11's Avatar
    Join Date
    Aug 2000
    Location
    it look me along time to do that...
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ya, thanks i already did that. i was hoping that there would something built into php that would do that, but it is just a line anyways...
    PHP Code:
    <?
    $months  
    = array(=> 'January''February''March''April''May''June''July''August''September''October''Novermber''December');
    echo 
    "$months[$mnth]";
    // $mnth is the month pulled from the database
    ?>


    thanks for the help anyways....
    I will Tell you what is wrong with your website and maybe what you can do to make it better.
    Professional Web Site Reviews ... Usability ...
    Contact Me god@stillsucks.com for more information ...
    look at my other reviews, to see what i have done.

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is this way also:

    PHP Code:
    function month_name($month) {
        return 
    date("M"mktime(0,0,0,$month,1,date("Y")))."<br>";
        }


    //Sample Usage
    print month_name(4); 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Addict
    Join Date
    Dec 2000
    Location
    BOSTON MA
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you're entering the current month why wouldn't you just use

    Code:
    $this_month = date("F");
    to get April ?
    . . . chris

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Chris I think he wants to just supply a month number and get its corresponding month name.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    SitePoint Enthusiast poil11's Avatar
    Join Date
    Aug 2000
    Location
    it look me along time to do that...
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ya the mktime! that will fit in there just perfectly. is it better to do that or just run an array? i could just run a test. that rocks, thanks a bunch...

    and ya i want to suply the month and get back april,may... or whatever. thanks again
    Last edited by poil11; Apr 9, 2001 at 13:43.
    I will Tell you what is wrong with your website and maybe what you can do to make it better.
    Professional Web Site Reviews ... Usability ...
    Contact Me god@stillsucks.com for more information ...
    look at my other reviews, to see what i have done.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •