Jump to content

[Need Help] php timing issues


matafy

Recommended Posts

:confused: I don't know what is going wrong. I need some help with being able to set an image at 9:00am Colorado time if my server is in California and it would be 8:00am. I tried to echo the image below, but it's not working.

 

<?php 
$hours_offset = -1; // Server time offset 
function currentImage(){  
    global $hours_offset; 
    $hour = date("H",(time()-(3600*$hours_offset))); 
    $imagePath = "img/";  
    if (date(H) < 09 || date(H) > 21) {  
    return $imagePath."".date(D)."/".$hour.".png"; 
    } 
?>

Link to comment
https://forums.phpfreaks.com/topic/178686-need-help-php-timing-issues/
Share on other sites

Would this work instead? This is what I came up with.

 

<?php
$hours_offset = -1; // Server time offset
function currentImage($hours_offset){ 
    $day = date(D)
    $hour = date("H",(time()-(3600*$hours_offset)));
    $imagePath = "img/"; 
    if ($hour < '09' || $hour > '21') { 
    return $imagePath."".$day."/".$hour.".png";
    }
?>

<?php echo currentImage($hours_offset);?>

After a little googling I came up with this:

<?php
date_default_timezone_set('America/Denver');

echo date_default_timezone_get() . '<br ><br >';

echo date("H:i:s");

?>

 

Output:

America/Denver

23:21:06

 

A touch out (+4 maybe 5 seconds) but shouldn't really matter?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.