Showing 1 - 1 of 1 total. RSS Feed WordPress RSS Feed

On This Page:

  1. 1  Detect daily saving times

    Detect daily saving times

    Thanks mainly to the efforts of a London builder named William Willett we have the controversial notion of daylight saving time (DST). This practice means that in some locations, all clocks are put one hour ahead of UTC time during the summer months.
    Well, if you use local time on your site (in a real time clock for example) and your site is viewed by someone out with the US, then at certain times of year the time on your clock will be out by an hour. In the case of Europe, between the last Sunday in March and the first Sunday in April the local time on your machine will be one hour ahead of Flash local time.

    This small script check the DST accordingly to US convention (first sunday of April last sunday of October) and can be adjusted for your needs in different countires.
    var start:Date = new Date()

    var startCounter:int = 1;
    start.setMonth(3, startCounter);

    for(var i:int = 0; i < 10; i++){

    startCounter++
    start.setMonth(3, startCounter)

    if(start.getDay() == 0){

    break;

    }

    }

    var end:Date = new Date();
    var endCounter:int = 31;

    end.setMonth(3, endCounter);

    for(var j:int = 0; j < 10; j++){

    endCounter--;
    end.setMonth(9, endCounter)

    if(end.getDay() == 0){

    break;

    }

    }

    trace("start date", start)
    trace("end date", end)
    Showing 1 - 1 of 1 total. RSS Feed WordPress RSS Feed

    On This Page:

    1. 1  Detect daily saving times