Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
What's wrong with my PHP date

It's 6:32 PM EST yet H is being returned as 22. I would expect it to be 18. PHP is version 5.3.9

What am I doing wrong here?

<?php 
$time = date("H");

if( $time >= 06 && $time < 10 )
$img_name = 'sunrise.jpg';
if( $time >= 10 && $time < 17 )
$img_name = 'day.jpg';
if( $time >= 17 && $time < 19 )
$img_name = 'sunset.jpg';
if( $time >= 19 && $time < 06 )
$img_name = 'night.jpg';


?>
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Two possible things:

  1. Your server time could be off. Check the server it is hosted on to make sure it's not

  2. Set a timezone. We can tell PHP which timezone to use by doing this:

    date_default_timezone_set('America/Los_Angeles');

You can view a list of supported timezones here: http://php.net/manual/en/timezones.php

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda