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
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);?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.