get date time code example

Example 1: python get date and time

import datetime
now = datetime.datetime.now()
print ("Current date and time : ")
print (now.strftime("%Y-%m-%d %H:%M:%S"))

Example 2: powershell get date

Get-Date

Tuesday, June 25, 2019 14:53:32

Example 3: powershell get date

Get-Date
   [[-Date] <DateTime>]
   [-Year <Int32>]
   [-Month <Int32>]
   [-Day <Int32>]
   [-Hour <Int32>]
   [-Minute <Int32>]
   [-Second <Int32>]
   [-Millisecond <Int32>]
   [-DisplayHint <DisplayHintType>]
   [-Format <String>]
   [<CommonParameters>]

Example 4: get current date datetime

from datetime import date

today = date.today()
print("Today's date:", today)

Tags:

Java Example