I've currently got
Get-Item "C:\path\to\file.txt" | ForEach-Object { $_.LastWriteTime }
Which outputs like this
12/18/2018 16:54:32
But I want it to output like this
12/18/2018 4:54 PM
Is there any way I can do that?
Use the DateTime objects formatting. More info here
Get-Item "C:\path\to\file.txt" | ForEach-Object {
$_.LastWriteTime.ToString("MM/dd/yyyy hh:mm:ss tt")
}
Much simpler to just use (Get-Date -Format 'M/d/yyyy h:mm tt')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With