PowerShell does an implicit conversion of a [datetime] to [string] in order to do this concatenation.
Why does using ToString() use the current regional settings while not using it produces a different result?
PS C:\> 'now ' + (Get-Date).AddDays(-3)
now 06/10/2023 12:32:28
PS C:\> 'now ' + (Get-Date).AddDays(-3).ToString()
now 2023-06-10 12:32:47
PS C:\> $PSVersionTable.PSVersion.ToString()
7.3.4
Related question: Why is Powershell Write-Output Date Format not the System Setting?
.ToString()will call theDateTime.ToString()instance method which uses the current culture, where as casting will use whatever the PowerShell team decided to use forIFormatProvider.I believe the code in charge of this is, which by the looks of it, they decided to useLanguagePrimitives.ConvertToInvariantCulture: LanguagePrimitives.cs#L1758C2-L1766.Type casting is actually handled by PSConvertBinder and they're also using
InvariantCulturethere: Binders.cs#L3765-L3795. ScriptBlockDisassembler Module makes it really easy to understand what internal classes are being used: