Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts

    Formating month in date()

    Script to show file creation date is as follows

    PHP Code:
    $filename "file.txt";
                    if (
    file_exists($filename)) {
                        echo 
    "<p class=\"ftime\">Dodano: " date ("d F Y H:i:s."filemtime($filename))."</p>";
                        } 
    it outputs something like

    01 January 2001

    How can i replace january with month in my language. i searched but couldn't find the answer.

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,151
    Thanks
    2
    Thanked 335 Times in 327 Posts
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts
    I still cant figure this one..
    If someone made a script to translate Month names into their own language, please share, or at least gimme a hint. I can't understand one on php.net page..

    Thank you

  • #4
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    Code:
    <? 
    if (eregi("functions_date.php",$PHP_SELF)) { // If accessed directly, 
    header("Location:../index2.php"); // Sends you to your index page (mine is outside my functions dir.)
    die();
    }
    ?>
    <?
    function conv_fecha($dia_larga) // this is the Day converter, mines does it to spanish
    {
    switch($dia_larga){
    case "Monday":
    $dia_larga="Lunes";
    return $dia_larga;
    break;
    case "Tuesday":
    $dia_larga="Martes";
    return $dia_larga;
    break;
    case "Wednesday":
    $dia_larga="Miercoles";
    return $dia_larga;
    break;
    case "Thursday":
    $dia_larga="Jueves";
    return $dia_larga;
    break;
    case "Friday":
    $dia_larga="Viernes";
    return $dia_larga;
    break;
    case "Saturday":
    $dia_larga="Sabado";
    return $dia_larga;
    break;
    case "Sunday":
    $dia_larga="Domingo";
    return $dia_larga;
    break;
    }}
    ?>
    <?
    function conv_mes($mes) // this is the Month converter, mines does it to spanish
    {
    switch($mes){
    case 1:
    $mes="Enero";
    return $mes;
    break;
    case 2:
    $mes="Febrero";
    return $mes;
    break;
    case 3:
    $mes="Marzo";
    return $mes;
    break;
    case 4:
    $mes="Abril";
    return $mes;
    break;
    case 5:
    $mes="Mayo";
    return$mes;
    break;
    case 6:
    $mes="Junio";
    return $mes;
    break;
    case 7:
    $mes="Julio";
    return $mes;
    break;
    case 8:
    $mes="Agosto";
    return $mes;
    break;
    case 9:
    $mes="Septiembre";
    return $mes;
    break;
    case 10:
    $mes="Octubre";
    return $mes;
    break;
    case 11:
    $mes="Noviembre";
    return $mes;
    break;
    case 12:
    $mes="Diciembre";
    return $mes;
    break;
    }}
    ?>
    <?
    $dia_larga= date("l");
    $dia=date("j");
    $mes=date("n");
    $year=date("Y");
    // SENDS THE DAY AND MONTH TO THE FUNCTIONS TO BE CONVERTED
    $dia_larga=conv_fecha($dia_larga);
    $mes=conv_mes($mes);
    ?>
    i found this on another forum hopefully this will do what you want. if you want to convert into different languages you will have to enter them into this.

    Thanks to carrzco Date Converter


  •  

    Posting Permissions

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