Add -FromUnixTime to Get-Date to allow Unix time input#12179
Add -FromUnixTime to Get-Date to allow Unix time input#12179TravisEz13 merged 11 commits intoPowerShell:masterfrom
-FromUnixTime to Get-Date to allow Unix time input#12179Conversation
test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetDateCommand.cs
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1
Outdated
Show resolved
Hide resolved
|
Upon specifying UTC in the tests, I noticed a small inconsistency. When specifying the DateTime with ticks, or with unix time, the This was causing issues when combined with the To get around this, we can set the to |
src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetDateCommand.cs
Outdated
Show resolved
Hide resolved
This reverts commit c76eebe.
|
@jackdcasey Please create new issue in PowerShell-Docs repo for the new parameter and add reference in the PR description. Thanks! |
|
Opened issue in MicrosoftDocs/PowerShell-Docs: MicrosoftDocs/PowerShell-Docs#5727 |
-FromUnixTime to Get-Date to allow Unix time input
|
@jackdcasey Thanks for your contribution! |
|
@iSazonov Thank you for all the help! |
|
🎉 Handy links: |
|
Negative UnixTime is not supported? |
|
@aetos382 No. If you have a feature request please open new issue. |
PR Summary
My proposal, is to add a
-FromUnixTimeswitch to Get-Date.This allows the input of a Unix timestamp into
Get-Date. This is currently impossible, as the default unit for a numeric input is ticks.Adding this switch would allow the user to specify if the input is Unix time, while also keeping full previous compatibility with ticks.
Here is an example output with, and without the switch:
PR Context
Closes #11719
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.