PowerShell- How to format DateTime
Today in this article, we shall see various examples of PowerShell- How to format DateTime.
We will cover below a few basic samples of PowerShell datetime format,
PowerShell Format DateTime – yyyy-MM-dd
In this PowerShell date format, we will define the Date field as “yyyy-MM-dd” format.
Example 1
$currentDate= (Get-Date).ToString('yyyy-MM-dd')
Write-Output $currentDate
PowerShell Format DateTime – yyyMMdd
Example 2
$currentDate= (Get-Date).ToString('yyyMMdd')
Write-Output $currentDate
PowerShell Date format- yyyy-MM-dd HH:mm:ss
Example 3
DateTime using PowerShell with timestamp HH:mm:ss
$currentDate= (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')
Write-Output $currentDate
Do you have any comments or ideas or any better suggestions to share?
Please sound off your comments below.
Happy Coding !!
Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.