Search code examples
angulartypescriptmomentjsmoment-timezone

how to get current EST time in angular considering with date light saving


I am new to angular. I need to get the current EST time with considering daylight saving.I gone through getTimeOffset. But I couldn't get it with daylight approach and with 24 hours format.

In case 05:00 PM EST, I need value as 16:00. Please help me on this


Solution

  • We can use below code to get EST time in angular

    let dd = new DatePipe('en-Us').transform(new Date(), 'HH' , 'EDT');
    
    if(parseInt(dd) >= 17){
    console.log("Time is greater than 05:00 PM EST");
    }else{
    console.log("Time is less than 05:00 PM EST");
    }