Date Time in Python

#----------------------------- 1 - installing datetime library -----------------------

i). Go to command prompt
ii). After opening type : pip install datetime  or type : ( python -m pip install datetime )
 
#----------------------------- 2 - Retrieving the todays information  ----------------

import datetime  # pip install datetime

today = datetime.datetime.now()
print(today) # give the current date , time in Hr.Min.Sec
#----------------------------- 3 -  Retrieving the specified date informations -------

import datetime as dt # pip install datetime

year = dt.datetime(2023,10,10,1,3)  #(year, month, day, Hours, Minutes, Seconds)

print(year.year)    # gives the current year

print(year.strftime("%A"))  # %A gives the day

print(year.strftime("%B"))  # %B gives the Month

print(year.strftime("%C"))  # %C gives the Century

print(year.strftime("%D"))  # %D gives the Date

print(year.strftime("%H"))  # %A gives the Hour

print(year.strftime("%j"))  # % j gives the day number (from 1 - 366)

print(year.strftime("%M"))  # %M gives the Minutes

print(year.strftime("P"))  # %P gives the mode of time  (AM/PM)

print(year.strftime("%T"))  # %T gives the time format (HH:MM:SS)

print(year.strftime("%Y"))  # %Y gives the Year

print(year.strftime("%z"))  # %Z gives the Time zone 

Join our team, where career growth knows no limits.

For More Details

Our internship program guarantees personalized attention for optimal career development in the tech industry.

+91 97879 68375

-> You should bring your own laptop during the internship

Who can apply?

Internships are open for students who: B.E / B.Tech / M.E / M.Tech / B.Sc / M.Sc / M.C.A / B.C.A / Diploma.

  • Ongoing Students Only
  • days, 5days/ 10days or Based on Student Preference
  • Limited 1 to 10 students per slot
  • Registration fees : 1000 INR
  • Slots are filling quickly only fewer slots are available