Weather station scripts

They're free, but use at your own risk

The scripts referenced here are used in the operation of this weather station, and may be freely copied and used to support your station. Please note that you use these scripts at your own risk. No warranty is expressed or implied. I accept no liability for any damages that may ensue from their use.
You will need to configure them for your own particular weather station website.
RSS feed for Scripts Updates A RSS Feed is available to help keep you informed on updates to the scripts.

Many of these scripts are now available on GitHub at

Buy Me A Coffee If you find one or more of the scripts useful to you, please consider making a donation to help offset the routine expenses of operation of this website.
Thanks for your kind support!

A Version History is available -- check back from time to time to see if there are updates to scripts you have downloaded earlier. Announcements of version updates and new scripts are made on and Weather-Watch forums and saratogaWXPHP Twitter account as they become available.

Note: Twitter widget has been disabled 3-Jul-2023 since it no longer displays the recent update Tweets.

This page was updated Friday, 12-Feb-2021 9:56 AM

UV Index forecast by latitude/longitude

I've received permission from KNMI/EMA to use their handy multi-day UV-Index forecast which is based on latitude and longitude of the location. There is a requirement that you credit them as copyright holders as shown in the example below. The $requiredNote string contains the required text. The program doesn't print anything (except HTML comments) when run and is designed to be included in your page (see below). The only required settings are:

// -------------Settings ---------------------------------
$cacheFileDir './';      // default cache file directory
$myLat '37.27153397';    //North=positive, South=negative decimal degrees
$myLong '-122.02274323';  //East=positive, West=negative decimal degrees
$ourTZ "America/Los Angeles";  //NOTE: this *MUST* be set correctly to
// translate UTC times to your LOCAL time for the displays.
//  has the list of timezone names
//  pick the one that is closest to your location and put in America/Los_Angeles like:
//   America/Los_Angeles = "Europe/Paris";  
//   America/Los_Angeles = "Pacific/Auckland";
$commaDecimal false;     // =true to use comma as decimal point in UVfcstUVI
$dateOnlyFormat 'd M Y'// dd MON YYYY
// -------------End Settings -----------------------------

The script returns values in two arrays:
$UVfcstDate[n] contains the date of forecast in dd Mon yyyy format
$UVfcstUVI[n] contains forecast UVI in dd.d format
$UVfcstDOW[n] is the forecast Day Of Week ('Sunday' ... 'Saturday') from date('l',time()); (New in V1.02)
$UVfcstISO[n] is the forecast date in YYYYMMDD format. (New in V1.02)

where n=0...8 . The script wil return $UVfcstUVI[n] = 'n/a' if the forecast is not available.

New with Version 1.02 - the script will adjust the returned arrays so that the [0] entry is for today (based on the timezone setting).

To use in your page, this code will show the UV forecast for one day

"UV Forecast $UVfcstDate[0] is $UVfcstUVI[0] <br/><small>($requiredNote)</small>\n";
UV Forecast 19-Jul-2024 is 9.5
(UV forecast courtesy of and Copyright © KNMI/ESA ( Used with permission.)

This code will show the available forecasts with with text description and the required copyright note appears as a tooltip when you mouse over the UV values.

//  decode UV to word+color for display

function getUVword (  $inUV ) {
// figure out a text value and color for UV exposure text
//  0 to 2  Low
//  3 to 5     Moderate
//  6 to 7     High
//  8 to 10 Very High
//  11+     Extreme
$uv preg_replace('|,|','.',$inUV); // in case decimal comma option is selected
switch (TRUE) {
     case (
$uv == 0):
$uv 'None';
     case ((
$uv 0) and ($uv 3)):
$uv '<span style="border: solid 1px; background-color: #A4CE6a;">&nbsp;Low&nbsp;</span>';
     case ((
$uv >= 3) and ($uv 6)):
$uv '<span style="border: solid 1px;background-color: #FBEE09;">&nbsp;Medium&nbsp;</span>';
     case ((
$uv >=) and ($uv 8)):
$uv '<span style="border: solid 1px; background-color: #FD9125;">&nbsp;High&nbsp;</span>';
     case ((
$uv >=) and ($uv 11)):
$uv '<span style="border: solid 1px; color: #FFFFFF; background-color: #F63F37;">&nbsp;Very&nbsp;High&nbsp;</span>';
     case ((
$uv >= 11) ):
$uv '<span style="border: solid 1px; color: #FFFF00; background-color: #807780;">&nbsp;Extreme&nbsp;</span>';
// end switch
return $uv;
// end getUVword


for ($i=0;$i count($UVfcstUVI); $i++) { ?>
UV forecast: <?php echo $UVfcstDate[$i?> is 
<a href="<?php echo htmlspecialchars($UV_URL); ?>" title="<?php echo strip_tags($requiredNote); ?>">
<b><?php echo $UVfcstUVI[$i]; ?></b></a>&nbsp;&nbsp;<?php echo getUVword($UVfcstUVI[$i]); ?><br/><br/> 
<?php // end for loop ?>  
UV forecast: 19-Jul-2024 is 9.5   Very High 

UV forecast: 20-Jul-2024 is 9.6   Very High 

UV forecast: 21-Jul-2024 is 9.3   Very High 

UV forecast: 22-Jul-2024 is 9.9   Very High 

UV forecast: 23-Jul-2024 is 10.2   Very High 

UV forecast: 24-Jul-2024 is 9.5   Very High 

Download: get-UV-forecast-inc.php (V1.09 - 12-Feb-2021) (see Version History)
(note: this script is included with the AJAX/PHP website templates)