Commands / System

Get-Date

Get the current date and time

beginner System

Get-Date
 Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
Works on
WindowsLinuxmacOS
PowerShell
5.1 and later
Reference
Microsoft Learn: Get-Date

Returns a DateTime. -Format uses .NET format strings. yyyy-MM-dd is the one you want in file names.

Try this

Get-Date
(Get-Date).AddDays(-7)

Coming from another shell

ShellWhat you might type
bash / zshdate '+%Y-%m-%d %H:%M:%S'
cmd.exeecho %date% %time%

More in From bash and From cmd.

Related commands