PDA

View Full Version : Using EST timezone as a base in javascript


harmor19
09-12-2008, 11:22 PM
I'm trying to make a javascript someone asked me to make for a MMO. I would like to base the subtractions off of EST timezone.
Here's the script http://xenweb.net/aeriagames/j-event.html.


<script type="text/javascript">
<!--
var currentTime = new Date()
var hours = currentTime.getHours()
//hours = 0
var minutes = currentTime.getMinutes()
if (minutes < 10)
minutes = "0" + minutes
//document.write(hours + ":" + minutes + "<br />")
if(hours > 11){
var ampm = "PM"
} else {
var ampm = "AM"
}

//Start Paldo
if(ampm == "AM" && hours < 8)
{
var paldohour = 8 - hours
var paldominute = 59 - minutes
}

if(ampm == "AM" && hours >= 8)
{
var paldohour = 19 - hours
var paldominute = 59 - minutes
}

if(ampm == "PM" && hours < 20)
{
var paldohour = 19 - hours
var paldominute = 59 - minutes
}

if(ampm == "PM" && hours >= 20)
{
var paldohour = 31 - hours
var paldominute = 59 - minutes
}
//End Paldo


//Start Resistance Battle

var rbhour = 21 - hours
var rbminute = 59 - minutes

//End Resistance Battle


//Text To be Displayed
var Paldo = "Paldo Starts in " +paldohour+ " hours and " +paldominute+ " minutes"
var RB = "Resistance Battle Starts in " +rbhour+ " hours and " +rbminute+ " minutes"
//-->
</script>