Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Change style based on time/date?
I'd like to automagically switch to a darker theme at night. Is this possible?
0
This discussion has been closed.
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.