# Countdown with getTimezoneOffset for CST

**URL:** <https://forum.kirupa.com/t/countdown-with-gettimezoneoffset-for-cst/249705>\
**Category:** flash\
**Created:** [January 21, 2008, 9:47pm UTC](https://forum.kirupa.com/t/countdown-with-gettimezoneoffset-for-cst/249705 "2008-01-21T21:47:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![smilker](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@smilker](https://forum.kirupa.com/u/smilker)\
**Post date:** [January 21, 2008, 9:47pm UTC](https://forum.kirupa.com/t/countdown-with-gettimezoneoffset-for-cst/249705/1 "2008-01-21T21:47:33Z")

</div>

Hello All,  
I found a tutorial on how to create a countdown timer using AS2. It works great but now I need to add more actionscript. Our company is releasing a brand launch in Chicago (CST) so I want the countdown timer to be the same for everyone’s computer, even if they are in NY for example. I did a trace for the offset and it returned -6hr (360min). How do I add the offset, can someone show me how to do this in actionscript please? I looked everywhere but I could not find it. I want to grab the time from the user’s computer and then add the getTimezoneOffset and subtract -6hr or 360min right?  
Also, I just thought of this - when the clock hits 0 or a negative value… I want to tell my flash piece to go to the next frame so they don’t see the clock counting backwards. 🙂  
I pasted my AS code below and attached is my fla.  
I appreciate any help.  
Thank you,  
Steve

this.onEnterFrame = function() {  
var today:Date = new Date();  
trace(today.getTimezoneOffset());  
var currentYear = today.getFullYear();  
var currentTime = today.getTime();  
var targetDate:Date = new Date(currentYear,01,19);//12 am Feb 19th

var targetTime = targetDate.getTime();

var timeLeft = targetTime - currentTime;  
var sec = Math.floor(timeLeft/1000);  
var min = Math.floor(sec/60);  
var hrs = Math.floor(min/60);  
var days = Math.floor(hrs/24);  
sec = string(sec % 60);  
// would like to check if seconds are 0 or negative, if they are go to another frame  
if (sec.length \< 2) {  
sec = “0” + sec;  
}  
min = string(min % 60);  
if (min.length \< 2) {  
min = “0” + min;  
}  
hrs = string(hrs % 24);  
if (hrs.length \< 2) {  
hrs = “0” + hrs;  
}  
days = string(days);  
var counter:String = days + " " + hrs + " " + min + " " + sec;  
time\_txt.text = counter;  
}
