Help with date conversion (spanish)

Discussion in 'PHP' started by hipromx, Jun 10, 2011.

  1. #1
    I have a date stored in a class variable with the format mm/dd/aaaa (cause it's spanish)
    How can I convert it to a string in spanish?
    For example:
    I have 06/10/2011
    convert that to: Viernes 10 de Junio de 2011.

    Can someone please guide me on this?

    Thank you.
     
    Last edited: Jun 10, 2011
    hipromx, Jun 10, 2011 IP
  2. Alastair Gilfillan

    Alastair Gilfillan Active Member

    Messages:
    120
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #2
    Here's a start. You're on your own in regards to figuring out the name of the day! :p
    <?php
    $initial_date = '06/10/2011';
    $date = explode('/', $initial_date);
    $months = array(
    	'01' => 'enero',
    	'02' => 'febrero',
    	'03' => 'marzo',
    	'04' => 'abril',
    	'05' => 'mayo',
    	'06' => 'junio',
    	'07' => 'julio',
    	'08' => 'agosto',
    	'09' => 'setiembre',
    	'10' => 'octubre',
    	'11' => 'noviembre',
    	'12' => 'diciembre',
    );
    $day = $date[1];
    $month = $months[$date[0]];
    $year = $date[2];
    echo $day.' de '.$month.' de '.$year.'.';
    ?>
    PHP:
     
    Alastair Gilfillan, Jun 10, 2011 IP
  3. hipromx

    hipromx Active Member

    Messages:
    236
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #3
    It works man, thank you! :D
     
    hipromx, Jun 10, 2011 IP
  4. Alastair Gilfillan

    Alastair Gilfillan Active Member

    Messages:
    120
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #4
    Happy to help. :)
     
    Alastair Gilfillan, Jun 10, 2011 IP