Forecast for a specific date

  • 1
  • Question
  • Updated 6 years ago
Can I get a weather forecast for a specific date? I realize I could code this in PHP but looking for something quick and dirty. I really only need a html sticker that shows forecast for a specific date. We have an event on Nov 10th and I'd to keep the forcast up to date.
Photo of markbannister

markbannister

  • 2 Posts
  • 0 Reply Likes

Posted 6 years ago

  • 1
Photo of markbannister

markbannister

  • 2 Posts
  • 0 Reply Likes
This is somewhat right. Should get someone started. Using this is a Drupal block to display weather for an event.
< $datetime2){
$current = gmdate("Y-m-d", strtotime("+1 day", strtotime($current)));
$count++;
}
return $count;
}

$apikey = 'YOUR API KEY HERE';
$locationstring = "AL/Huntsville";
$json_string = file_get_contents("http://api.wunderground.com/api/".$ap...");

$data = json_decode( $json_string );

$event_date = '2012-11-10'; //date of event you want

$todaydate =new DateTime("now");
$now = $todaydate?>format('Y-m-d' );
$interval = date_diff_cust( $now,$event_date ); //does not check for out of 10 day range yet

echo "
".$data->forecast->txt_forecast->forecastday[ $interval ]->fcttext ;
echo "
" ;
echo "
".$data->forecast->simpleforecast->forecastday[ $interval ]->date->weekday ." ".
$data->forecast->simpleforecast->forecastday[ $interval ]->date->month ."/".$data->forecast->simpleforecast->forecastday[ $interval ]->date->day ."/". $data->forecast->simpleforecast->forecastday[ $interval ]->date->year;

?>