Code For Setting the date as date before three days





We need to convert the current date to US time zone and need to find the date before three days ago from this.We can use the below code to achieve this.

//obtain the current date
 var  date =new Date();
//converting current date to US time zone
                var usTime = format.format({
                    value : date,
                    type : format.Type.DATETIME,
                    timezone : format.Timezone.AMERICA_NEW_YORK
                }); 
//setting the date as date before three days
               var us_date=new Date(usTime.split(' ')[0]);
                us_date.setDate(us_date.getDate() - 3);
                var threedaysago = (us_date.getMonth()+1)+'/'+ us_date.getDate()              +'/'+us_date.getFullYear();

Leave a comment

Your email address will not be published. Required fields are marked *