Page 1 of 1

Convert Daily Range Between Fahrenheit and Celsius

Posted: Fri 05 Jul 2013 7:36 pm
by Buford T. Justice
On my weather webpages, I use a small script to convert Fahrenheit to Celsius (or vice versa) so both temperatures are shown as Fahrenheit | Celsius. Using the example of the year's highest temperature, here is the HTML code I use to show both Fahrenheit and Celsius using Celsius data:

Code: Select all

<script>tempF1 = <#YearTempH> * 1.8 + 32;document.write(tempF1.toFixed(0));</script> °F | <#YearTempH> <#tempunit>
And here is the same thing using Fahrenheit data:

Code: Select all

<#YearTempH> <#tempunit> | <script>tempC1 = (<#YearTempH> - 32) / 1.8;document.write(tempC1.toFixed(1));</script>
The problem I running into using these codes deals with the daily ranges. I know they are determined by subtracting the low from the high temperature, but there must be a way to do it to where I can show the range as both Fahrenheit and Celsius. I cannot figure out a way to do this Might someone out there know?

Re: Convert Daily Range Between Fahrenheit and Celsius

Posted: Fri 05 Jul 2013 7:50 pm
by steve
To convert a temperature difference between deg C and deg F, just multiply/divide by 1.8 as appropriate.

Re: Convert Daily Range Between Fahrenheit and Celsius

Posted: Fri 05 Jul 2013 8:43 pm
by Buford T. Justice
Oh of course! Every 1 °C = 1.8 °F. Ever have one of those days you can't remember simple things like that? LOL! Thanks.