Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    6

    Unanswered: Unix Date to Regular Date

    Is there a php function that takes the unix timestamp 2003-12-18 and changes it to December 18, 2003? If there isn't a command how could I go about doing this? Thanks!

  2. #2
    Join Date
    Dec 2003
    Posts
    31
    Originally posted by dhoyos
    Is there a php function that takes the unix timestamp 2003-12-18 and changes it to December 18, 2003? If there isn't a command how could I go about doing this? Thanks!
    Well here is some really quick code that could get you started...
    PHP Code:
    <?php
    $var 
    "2003-12-18";
    list(
    $year$month$day) = split("-"$var3);

    switch(
    $month) { 
        case 
    "1"$month="Jan."; break; 
        case 
    "2"$month="Feb."; break; 
        case 
    "3"$month="Mar."; break; 
        case 
    "4"$month="Apr."; break; 
        case 
    "5"$month="May"; break; 
        case 
    "6"$month="June"; break; 
        case 
    "7"$month="July"; break; 
        case 
    "8"$month="Aug."; break; 
        case 
    "9"$month="Sept."; break; 
        case 
    "10"$month="Oct."; break; 
        case 
    "11"$month="Nov."; break; 
        case 
    "12"$month="Dec."; break; 
    }

    echo 
    $month " " $day ", " $year;
    ?>

  3. #3
    Join Date
    Jul 2003
    Location
    Jersey
    Posts
    11

    Re: Unix Date to Regular Date

    Originally posted by dhoyos
    Is there a php function that takes the unix timestamp 2003-12-18 and changes it to December 18, 2003? If there isn't a command how could I go about doing this? Thanks!
    http://us2.php.net/manual/en/function.date.php

    $var = "2003-12-18";
    list($year, $month, $day) = split("-", $var, 3);

    $timestamp = mktime(0,0,0,$month,$day,$year);

    echo date("F j, Y",$timestamp);


    (i stole some of the other guys stuff.. though i've never used 'list' before, but it looks like that should work.)

    (acutally, tested it and it's good). (killing time at working and not coding what i should be...)

Posting Permissions

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