Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!