This would require an extension, which I have no idea how to create. But you also need to kind in mind that since most fora (?) are global, the extension will need to understand people's local time settings, otherwise it will be pretty weird having the style (or theme) change to a night time theme when it's the middle of the day!
I do think this would be a pretty cool extension for the community however, so I'm going to bookmark this discussion for future reference.
Let me know how you progress with this time-check. I am also working on doing a time-check in a new extension I am working on. I'm trying to use gmt time.
Edit: I did get my function to work using the date(). Here is my code:
function check_time(&$Context) {
global $compare_time;
$compare_time = "";
if (file_exists($Context->Dictionary["GRAPH_FILE"])) {
$compare_time = date ("Y-m-d H:i:s", filemtime($Context->Dictionary["GRAPH_FILE"]));
list($year, $month, $day, $hour, $minute, $second ) = sscanf($compare_time, "%d-%d-%d %d:%d:%d");
$thatdate = mktime( $hour, $minute, $second, $month, $day, $year );
$now = date("Y-m-d H:i:s",time());
// echo $now."-".TimeAgo($thatdate);
$timeparts = explode(' ',$compare_time);
$strt = $timeparts[1];
$starttime = $strt.substr($timeparts[0],1);
$timeparts = explode(' ',$now);
$endt = $timeparts[1];
$endtime = $endt.substr($timeparts[0],1);
$diff = $endtime - $starttime;
// echo $strt."-".$endt."--- ".$diff." ***";
if ($diff > $Context->Dictionary["GRAPH_TIME"]) return true;
return false;
}
return false;
}
I'm generating an image file, but only want to do it once a day (at midnight). I'm using the timestamp on the image file to compare against. If it's older than 23 hours, then I will regenerate the image file. If anyone sees any problems with this, please let me know.
Comments
I do think this would be a pretty cool extension for the community however, so I'm going to bookmark this discussion for future reference.
Edit: I did get my function to work using the date(). Here is my code:
function check_time(&$Context) { global $compare_time; $compare_time = ""; if (file_exists($Context->Dictionary["GRAPH_FILE"])) { $compare_time = date ("Y-m-d H:i:s", filemtime($Context->Dictionary["GRAPH_FILE"])); list($year, $month, $day, $hour, $minute, $second ) = sscanf($compare_time, "%d-%d-%d %d:%d:%d"); $thatdate = mktime( $hour, $minute, $second, $month, $day, $year ); $now = date("Y-m-d H:i:s",time()); // echo $now."-".TimeAgo($thatdate); $timeparts = explode(' ',$compare_time); $strt = $timeparts[1]; $starttime = $strt.substr($timeparts[0],1); $timeparts = explode(' ',$now); $endt = $timeparts[1]; $endtime = $endt.substr($timeparts[0],1); $diff = $endtime - $starttime; // echo $strt."-".$endt."--- ".$diff." ***"; if ($diff > $Context->Dictionary["GRAPH_TIME"]) return true; return false; } return false; }
I'm generating an image file, but only want to do it once a day (at midnight). I'm using the timestamp on the image file to compare against. If it's older than 23 hours, then I will regenerate the image file. If anyone sees any problems with this, please let me know.