Ver Mensaje Individual
  #7 (permalink)  
Antiguo 19/10/2018, 10:54
Avatar de hhs
hhs
Colaborador
 
Fecha de Ingreso: junio-2013
Ubicación: México
Mensajes: 2.995
Antigüedad: 10 años, 10 meses
Puntos: 379
Respuesta: Función para mostrar fecha con horas

Alguna razón para no usar INTL?
Código PHP:
Ver original
  1. function localized_datetime( int $from_timestamp ) {
  2.     $date_time = (new DateTime())->setTimestamp( $from_timestamp );
  3.  
  4.     $intlDateFormatter = new IntlDateFormatter(
  5.         'es_ES',
  6.         IntlDateFormatter::NONE,
  7.         IntlDateFormatter::NONE,
  8.         'America/Mexico_City',
  9.         IntlDateFormatter::GREGORIAN,
  10.         "d 'de' MMMM YYYY, HH:mm"
  11.     );
  12.  
  13.     return  $intlDateFormatter->format( $date_time );
  14. }
  15.  
  16. echo localized_datetime(1539740681);
__________________
Saludos
About me
Laraveles
A class should have only one reason to change.

Última edición por hhs; 19/10/2018 a las 17:28