SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    http://TheICE.co.uk/ The Eerie Network's Avatar
    Join Date
    Apr 2001
    Location
    London in the UK.
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    my function won't work

    My small function is below

    PHP Code:
    // Date conversion $date is in yyyy-mm-dd format
    function dateconvert($date) {
        
    $year substr($date04);
        
    $month substr($date52);
        
    $day substr($date82);

        
    $month_list[01] = "January";
        
    $month_list[02] = "Febuary";
        
    $month_list[03] = "March";
        
    $month_list[04] = "April";
        
    $month_list[05] = "May";
        
    $month_list[06] = "June";
        
    $month_list[07] = "July";
        
    $month_list[08] = "August";
        
    $month_list[09] = "September";
        
    $month_list[10] = "October";
        
    $month_list[11] = "November";
        
    $month_list[12] = "December";

        return 
    $month_list[$month] . " " $day ", " $year ".";

    My problem is that all it displays is the day and year, but not the month, i'm sure it has somthing to do with the "$month_list[$month]" section, but I don't know.
    Daniel Hollands
    New: My Webcam <-- Come and watch me doing what I do
    TheICE.co.uk <-- New sites for the best in UK lifestyle and Competitions.
    The ofDan.Network Forums <-- Come and join in the fun.

  2. #2
    SitePoint Zealot alexk's Avatar
    Join Date
    Nov 2000
    Location
    Sydney, Australia
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i believe you need to convert $month to integer... eg (int)$month

  3. #3
    http://TheICE.co.uk/ The Eerie Network's Avatar
    Join Date
    Apr 2001
    Location
    London in the UK.
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That worked a charm, thank you :-)
    Daniel Hollands
    New: My Webcam <-- Come and watch me doing what I do
    TheICE.co.uk <-- New sites for the best in UK lifestyle and Competitions.
    The ofDan.Network Forums <-- Come and join in the fun.

  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)
    Or you can use strtotime() in conjunction with date() to achieve the same result without the headache.

    PHP Code:
    $date '2001-08-21';
    print 
    date("F d, Y"strtotime($date)); // Prints August 21, 2001 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •