Timeconversion from IST to EST using powershell

Azure-learning 56 Reputation points
2022-09-17T07:36:03.73+00:00

I have to convert time from IST to EST using powershell while running the script in automation runbook. It's taking IST time zone .
below is my code which is giving output in IST.

How to print 15 PM EST using powershell .

$A = Get-Date '15:00'

This is coming in IST .but I want $A value to be 15 PM EST (static value) . how to write it using powershell

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,366 questions
Windows for business Windows Server User experience PowerShell
{count} votes

2 answers

Sort by: Most helpful
  1. Andreas Baumgarten 123.4K Reputation points MVP Volunteer Moderator
    2022-09-17T09:32:50.233+00:00

    Hi @NGaur-3476 ,

    maybe this helps:

    $tzName = "Central European Standard Time"  
    $cestDateTime = [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId((Get-Date), $tzName)  
    $tzName = "India Standard Time"  
    $istDateTime  = [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId((Get-Date), $tzName)  
    $tzName = "Eastern Standard Time"  
    $estDateTime = [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId((Get-Date), $tzName)  
      
    $cestDateTime  
    $istDateTime   
    $estDateTime  
    

    The result will look like this:

    242107-image.png

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


  2. Andreas Baumgarten 123.4K Reputation points MVP Volunteer Moderator
    2022-09-19T05:58:20.08+00:00

    Hi @NGaur-3476 ,

    please try this to work with a static time instead of the current time:

    $tzName = "Eastern Standard Time"  
    [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId((Get-Date '15:00'), $tzName)  
    

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.