format('m/d/Y_H:i:s'); //Add new temp $lines[] = "$date $lastTemp"; //Reduce down to up to 100 lines, 25 hours $lines = array_slice($lines, -$maxLines); //Write back to log file file_put_contents($filename, implode(PHP_EOL, $lines) . PHP_EOL); echo "Temp updated successfully [$lastTemp], keeping the last $maxLines lines."; exit(); } //Default display the data //Create the dateStr and dataStr $first = true; $dateStr = ""; $dataStr = ""; $dateName = ""; foreach ($lines as $line) { $rawData = explode(" ", $line); $rawDate = explode("_",$rawData[0]); $rawDateParts = explode("/",$rawDate[0]); $rawTimeParts = explode(":",$rawDate[1]); //new Date(Date.UTC(Year, Month, Day, Hours, Minutes, Seconds, Milliseconds)) $month = $rawDateParts[0]-1; $dateObjStr = "new Date($rawDateParts[2], $month, $rawDateParts[1], $rawTimeParts[0], $rawTimeParts[1], $rawTimeParts[2], 0)"; if ($first) { $first = false; $dateName = $rawDate[0]; $dateStr = "$dateObjStr"; $dataStr = $rawData[1]; } else { $dateStr = $dateStr . ",$dateObjStr"; $dataStr = $dataStr . ",$rawData[1]"; } } ?>