Search
Sponsors

Archive for the ‘Functions’ Category

Generate a Unique ID

Sunday, February 14th, 2010

function uniqeid()
{
var newDate = new Date;
return newDate.getTime();
}

Temperature conversions

Sunday, January 11th, 2009

function celsiusToFahrenheit(t)
{
return (212-32)/100 * t + 32;
}

function fahrenheitToCelsius(t)
{
return 100/(212-32) * (t - 32);
}

MB to KB

Saturday, January 10th, 2009

function mbToKb(MB)
{
return MB * 1024;
}

Time conversion functions

Friday, January 9th, 2009

function hoursToMinutes(hrs)
{
return hrs*=60;
}

function hoursToSeconds(hrs)
{
return hrs*=3600;
}

function minutesToHours(min)
{
var hrs = Math.floor(min/60);
min = min % 60;
if(min<10) min = “0″ + min;
return hrs + “:” + min;
}

function minutesToSeconds(min)
{
return min*=60;
}

function secondsToHours(sec)
{
var hrs = Math.floor(sec/3600);
var min = Math.floor((sec%3600)/60);
sec = sec % 60; if(sec<10) sec = “0″ + sec;
if(min<10) min = “0″ + min;
return hrs + “:” + min + “:” + sec;
}

function secondsToMinutes(sec)
{
var min = Math.floor(sec/60);
sec = sec % 60;
if(sec<10) sec = “0″ + sec;
if(min<10) min = “0″ + min;
return min + “:” + sec;
}

hex to decimal

Friday, January 9th, 2009

function hexToDec(hex)
{
return parseInt(hex,16);
}

Translate