3

Google weather API shows temperature in Fahrenheit.

After watching this post, I was able to convert temperature from F to C.

However, it shows like 17.222222222222° C - 28.888888888889° C, Clear. How can i make it only 17° C-28° C.

Thanks in advance.

Community
  • 1
  • 1
Adnan
  • 8,468
  • 9
  • 29
  • 45
  • **The Google weather API was shut down in 2012** -> http://stackoverflow.com/questions/12145820/google-weather-api-gone/35943521 – John Slegers Mar 11 '16 at 15:58

1 Answers1

7
function toCelsius($deg)
{
  return floor(($deg-32)/1.8);
}

You can use floor to return the next lowest integer value by rounding down value if necessary.

ajreal
  • 46,720
  • 11
  • 89
  • 119