Conversion of date saved in date format ('d-m-Y')

1

I am saving in my Database the date of the record in a field called Date , the input is of type date . It turns out that the data is being saved as follows 2017-11-28 , that's the least of it, the problem arises in which I must and want to show that data on my website as follows:

Desired result:

Viernes, 24 / Noviembre / 2017

The question is, how can I convert that date to the format I need?

My code:

//Fecha
$fecha = '2017-11-25';
//Imprimo.
echo $fecha;

Greetings.

    
asked by Alejo Mendoza 25.11.2017 в 00:02
source

1 answer

0

strftime - Formats a local date / time based on a local configuration.

setlocale - Set localism information.

A possible example:

//Establecer la información del localismo.
setlocale(LC_ALL, 'es_ES'); 
//Tu fecha
$fecha = '2017-11-25';
//Imrimimos fecha con la función 'strftime'.
echo utf8_encode(strftime("%A, %d de %B de %Y", strtotime($fecha))) . ".\n";

Result : Sábado, 25 de Noviembre de 2017 .

  

Note: If you want to use the / bar you should simply change the words de "%A, %d / %B / %Y" .

used formats :

  • %A A complete textual representation from Sunday to Saturday
  • %d The day of the month with two digits (with leading zeros) 01 to 31
  • %B Name of the full month, based on localism January up December
  • %Y Four-digit representation of the year Example: 2038
answered by 25.11.2017 / 00:22
source