Learn about Windows PowerShell
Summary: Learn how to use UNIX date formatting in Windows PowerShell.
How can I use my prior knowledge of UNIX date formatting to specify dates in Windows PowerShell?
Use the Get-Date cmdlet and the –Uformat parameter. For example, to display a date in standard format for your current locale, use the “x” format specifier:
PS C:\> Get-Date -UFormat %x
03/11/13
%s being the switch to convert to epoch time. Then...
Get-date $(Get-Date("10/07/1975 08:00")) -uFormat %s
to get a given date in epoch time, and the following function to convert back to date time in local time zone.
Function Get-DateFromEpoch ($EpochDate) {
[timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($EpochDate))
}
Get-DateFromEpoch("174211200")
Thursday, 10 July 1975 4:00:00 PM
Get the Epoch: www.coolepochcountdown.com