Results 1 to 3 of 3

Thread: change variable language

  1. #1
    Join Date
    Apr 2007
    Posts
    149
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default change variable language

    hello, i got this variable $todayis = date("l, F j, Y, g:i a") ; and i want to know how can i change it to display the date and time in another language. (i would mostly be using spanish). Thanks

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Hola.

    You can use the format as you want, for any international standard. Simply reformat the date, using the same setup.
    http://www.php.net/manual/en/function.date.php has a long list of formatting components. 'd' for example is day of the month.
    Any symbols or other characters that are NOT already used as part of the formatting will be displayed. For example, 'd:d' would output '01:01' if it was the first day of the month.

    If you want to standardize the input, you can use $var = time() to get the current timestamp.

    From $that, you can use date('format',$that); and output in any format you'd like.

    If you are talking about actually translating words, such as days of the week, you will want to create a replacement system for the string, as I don't think that PHP has any default translation for time like that.

    PHP Code:
    $todayis date(...);
    $dias = array(
    'monday'=>'lunes',
    'tuesday'=>'martes',
    'wednesday'=>'miercoles',
    'thursday'=>'jueves',
    'friday'=>'viernes',
    'saturday'=>'sabado',
    'sunday'=>'domingo'
    );
    $hoyes strtolower($todayis); //eliminate any weird capital letters
    foreach ($dias as $en=>$es) {
    $hoyes str_replace($en,$es,$hoyes);
    }
    //$hoyes ahora esta el tiempo en espaņol 
    Daniel - Freelance Web Design | <?php?> | <html>| espaņol | Deutsch | italiano | portuguęs | catalā | un peu de franįais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Apr 2007
    Posts
    149
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks alot djr33!! That worked just great!! Thanks Again!!

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
  •