From cd5c4968bdf2ed5ef2560afa0155222a3560ef4f Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Tue, 30 Jun 2026 11:12:08 -0500 Subject: [PATCH] Fixes #13116 - Update UFormat differences btw PS and Unix (#13118) * Update UFormat differences btw PS and Unix * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../5.1/Microsoft.PowerShell.Utility/Get-Date.md | 16 ++++++++++------ .../7.4/Microsoft.PowerShell.Utility/Get-Date.md | 11 +++++++---- .../7.5/Microsoft.PowerShell.Utility/Get-Date.md | 11 +++++++---- .../7.6/Microsoft.PowerShell.Utility/Get-Date.md | 11 +++++++---- .../7.7/Microsoft.PowerShell.Utility/Get-Date.md | 11 +++++++---- 5 files changed, 38 insertions(+), 22 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Get-Date.md b/reference/5.1/Microsoft.PowerShell.Utility/Get-Date.md index d49ea4ac30d0..b83b1193933e 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Get-Date.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Get-Date.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 04/30/2025 +ms.date: 06/30/2026 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-date?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: Get-Date @@ -556,13 +556,17 @@ The valid **UFormat specifiers** are displayed in the following table: | `%Z` | Time zone offset from Universal Time Coordinate (UTC) | -07 | > [!NOTE] -> Windows PowerShell's behavior with `Get-Date -UFormat %s` is incorrect in two respects: +> In Windows PowerShell, not all **UFormat** specifiers produce the same results as their Unix +> equivalents. For example: > -> - The return value is based on local time instead of UTC time. -> - The string representation of the seconds value has a fractional part. The output is -> culture-sensitive with respect to the decimal mark. +> - `Get-Date -UFormat %s` is incorrect in two respects: +> - The return value is based on local time instead of UTC time. +> - The string representation of the seconds value has a fractional part. The output is +> culture-sensitive with respect to the decimal mark. +> - The formats of `%c`, `%l`, `%k`, `%s`, `%j`, and `%V` aren't consistent with the ISO 8601 +> standard. > -> These behaviors have been fixed in PowerShell 6 and higher. +> These behaviors are fixed in PowerShell 6.1 and higher. ## RELATED LINKS diff --git a/reference/7.4/Microsoft.PowerShell.Utility/Get-Date.md b/reference/7.4/Microsoft.PowerShell.Utility/Get-Date.md index 8e57d208d5d0..97c1e204b85e 100644 --- a/reference/7.4/Microsoft.PowerShell.Utility/Get-Date.md +++ b/reference/7.4/Microsoft.PowerShell.Utility/Get-Date.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 04/30/2025 +ms.date: 06/30/2026 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-date?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 title: Get-Date @@ -657,10 +657,13 @@ The valid **UFormat specifiers** are displayed in the following table: | `%Z` | Time zone offset from Universal Time Coordinate (UTC) | -07 | > [!NOTE] -> The behavior of `-UFormat %s` was changed to fix problems with the behavior in Windows PowerShell. +> Not all **UFormat** specifiers produce the same results as their Unix equivalents. For example: > -> - The return value is based on UTC time. -> - The value is a whole number of seconds value (no fractional part). +> - In Unix-based systems, `%W` returns the week number of the year as a decimal number in the range +> 00 to 53, starting with the first Monday as the first day of week 01. All days before the first +> Monday of the year are in week 00. +> - In PowerShell, `%W` returns the week number of the year as a decimal number, range 1 to 53, with +> no leading zero and no week zero. The first week starts on the first day of the year. ## RELATED LINKS diff --git a/reference/7.5/Microsoft.PowerShell.Utility/Get-Date.md b/reference/7.5/Microsoft.PowerShell.Utility/Get-Date.md index 06232e579b94..ea06fb15682b 100644 --- a/reference/7.5/Microsoft.PowerShell.Utility/Get-Date.md +++ b/reference/7.5/Microsoft.PowerShell.Utility/Get-Date.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 04/30/2025 +ms.date: 06/30/2026 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-date?view=powershell-7.5&WT.mc_id=ps-gethelp schema: 2.0.0 title: Get-Date @@ -657,10 +657,13 @@ The valid **UFormat specifiers** are displayed in the following table: | `%Z` | Time zone offset from Universal Time Coordinate (UTC) | -07 | > [!NOTE] -> The behavior of `-UFormat %s` was changed to fix problems with the behavior in Windows PowerShell. +> Not all **UFormat** specifiers produce the same results as their Unix equivalents. For example: > -> - The return value is based on UTC time. -> - The value is a whole number of seconds value (no fractional part). +> - In Unix-based systems, `%W` returns the week number of the year as a decimal number in the range +> 00 to 53, starting with the first Monday as the first day of week 01. All days before the first +> Monday of the year are in week 00. +> - In PowerShell, `%W` returns the week number of the year as a decimal number, range 1 to 53, with +> no leading zero and no week zero. The first week starts on the first day of the year. ## RELATED LINKS diff --git a/reference/7.6/Microsoft.PowerShell.Utility/Get-Date.md b/reference/7.6/Microsoft.PowerShell.Utility/Get-Date.md index 26c8f59d0119..dab606d27aa1 100644 --- a/reference/7.6/Microsoft.PowerShell.Utility/Get-Date.md +++ b/reference/7.6/Microsoft.PowerShell.Utility/Get-Date.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 03/19/2024 +ms.date: 06/30/2026 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-date?view=powershell-7.6&WT.mc_id=ps-gethelp schema: 2.0.0 title: Get-Date @@ -657,10 +657,13 @@ The valid **UFormat specifiers** are displayed in the following table: | `%Z` | Time zone offset from Universal Time Coordinate (UTC) | -07 | > [!NOTE] -> The behavior of `-UFormat %s` was changed to fix problems with the behavior in Windows PowerShell. +> Not all **UFormat** specifiers produce the same results as their Unix equivalents. For example: > -> - The return value is based on UTC time. -> - The value is a whole number of seconds value (no fractional part). +> - In Unix-based systems, `%W` returns the week number of the year as a decimal number in the range +> 00 to 53, starting with the first Monday as the first day of week 01. All days before the first +> Monday of the year are in week 00. +> - In PowerShell, `%W` returns the week number of the year as a decimal number, range 1 to 53, with +> no leading zero and no week zero. The first week starts on the first day of the year. ## RELATED LINKS diff --git a/reference/7.7/Microsoft.PowerShell.Utility/Get-Date.md b/reference/7.7/Microsoft.PowerShell.Utility/Get-Date.md index 93ea7528b343..bc918f74bbf7 100644 --- a/reference/7.7/Microsoft.PowerShell.Utility/Get-Date.md +++ b/reference/7.7/Microsoft.PowerShell.Utility/Get-Date.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 03/19/2024 +ms.date: 06/30/2026 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-date?view=powershell-7.7&WT.mc_id=ps-gethelp schema: 2.0.0 title: Get-Date @@ -657,10 +657,13 @@ The valid **UFormat specifiers** are displayed in the following table: | `%Z` | Time zone offset from Universal Time Coordinate (UTC) | -07 | > [!NOTE] -> The behavior of `-UFormat %s` was changed to fix problems with the behavior in Windows PowerShell. +> Not all **UFormat** specifiers produce the same results as their Unix equivalents. For example: > -> - The return value is based on UTC time. -> - The value is a whole number of seconds value (no fractional part). +> - In Unix-based systems, `%W` returns the week number of the year as a decimal number in the range +> 00 to 53, starting with the first Monday as the first day of week 01. All days before the first +> Monday of the year are in week 00. +> - In PowerShell, `%W` returns the week number of the year as a decimal number, range 1 to 53, with +> no leading zero and no week zero. The first week starts on the first day of the year. ## RELATED LINKS