I have a String that represents a time in Epoch and I need the correct format to be able to enter it in a SQL Server database, from PowerShell. So far I can change the Epoch format to a very long date format, EXAMPLE:
Date in Epoch to convert: 746181000
Function I use:
[timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds('746181000'))
The output is the following:
Tuesday, August 24, 1993 3:30:00 AM
What I really need is the date in this format:yyyy-MM-dd HH:MM:ss
So my desired output would be1993-08-24 03:30:00
You can do the following:
According to the function you defined above:
You can use the Get-Date command along with the Format parameter to manipulate the output as per your need, as follows: