Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Date problem with GMT

  • Date problem with GMT

    Posted by Pawel Barański on November 11, 2020 at 12:01 am

    Hello everyone, i have a little problem with Date script. I have date counter which is counting days from set date and count to some number of days whcich we can set too. The problem is with date 25th of october 2020. At my computer script place two dates 25/10 in list of counted dates. Anyone can tell me why AE change time zone and double some days with different time zone? Is there any way to get date without timezone or with UTC 0 or maybe it’s a “little bug” in AE? Thank you all for your help.

    here’s my simple script

    ///////////

    var day_slider = thisComp.layer(“CONTROL”).effect(“DAY”)(“Slider”); // set here “1”

    var month_slider = thisComp.layer(“CONTROL”).effect(“MONTH”)(“Slider”);// set here “10”

    var year_slider = thisComp.layer(“CONTROL”).effect(“YEAR”)(“Slider”);// set here “2020”

    var how_many_days = thisComp.layer(“CONTROL”).effect(“HOW_MANY_DAYS”)(“Slider”);// set here for example “60”

    var date_from_slider = month_slider+”.”+day_slider+”.”+year_slider;

    var msPerDay = 24*60*60*1000;

    var start_date = new Date(date_from_slider);

    var timer = start_date.getTime();

    var lista = new Array();

    for (j=0;j<=how_many_days;j++){

    my_variable = timer +(j * msPerDay);

    my_variable = new Date(my_variable);

    lista.push(my_variable+”\n”);

    }

    lista;

    ///////////////////////

    Filip Vandueren replied 5 years, 10 months ago 2 Members · 1 Reply
  • 1 Reply
  • Filip Vandueren

    November 11, 2020 at 1:22 pm

    Hi Pawel,

    25/10 is the day daylight savings time changes, so just adding 24 hours to the date, doesn’t bring you to the next day.

    Try this instead, it uses the feature of javascript that you can ask for day 40 of a month, or month 15 of a year etc. and it will give you the correct day in the next month/year.

    var day_slider = thisComp.layer("CONTROL").effect("DAY")("Slider");
    var month_slider = thisComp.layer("CONTROL").effect("MONTH")("Slider");
    var year_slider = thisComp.layer("CONTROL").effect("YEAR")("Slider");
    var how_many_days = thisComp.layer("CONTROL").effect("HOW_MANY_DAYS")("Slider");
    var start_date = new Date(0);
    start_date.setHours(0); // midnight
    var lista = new Array();
    for (j=0;j<=how_many_days;j++){
    start_date.setFullYear(year_slider);
    start_date.setMonth(month_slider-1);
    start_date.setDate(day_slider); // change the day last, so the year/month will automatically roll over
    lista.push(start_date+"\n");
    day_slider++;
    }
    lista;

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy