Skip to content

Spoke Right

Education for everyone

https://spokeright.com
Primary Menu
  • Home
  • Our Services
    • Translation
    • Interpretation
    • Transcription
    • Voice-Over
    • Proofreading
    • Content writing
  • Free Education
    • Learn Android Studio
    • Learn Python
    • Learn MongoDB
    • Learn MySql
    • Learn React
    • Montessori Education
  • Spoke Right News
  • Earn Online
  • Classic Games by Spoke Right
    • TicTac
    • Checkers
    • Foosball
    • Billiards
    • Master Chess
    • Logic Game
  • Contact Us
Download Now
  • Home
  • Learn Python
  • How do I get the date in Python
  • Learn Python

How do I get the date in Python

Spoke Right December 7, 2022 2 min read

Python Date

Python datetime module and Python time module both contains various built in functions and statements to deal with all type of date and time operations in the python code. Python facilitates numerous Date and Time features to its users that eases any required date and time interfacing in the program.

Python Datetime Module:

The datetime module returns information about the date object in various format. In normal scenario, the date retrieved contains current year, month, day, hour, minute, second, and even microsecond.

Python Time Module:

The ime module returns information about the time object in various format. In normal scenario, the time retrieved includes 9 attributes.

ATTRIBUTEEXPLANATION
tm_yearCurrent year
tm_monCurrent month
 tm_mdayCurrent month day
tm_hourCurrent hour
tm_minCurrent minute
tm_secCurrent seconds
tm_wdayWeek day
 tm_ydayYear day
tm_isdst-1,0 or 1

 

Python Time Module Methods:

FUNCTIONUSES
time()To get floating point value in seconds since epoch.
asctime()To get a 24 character string, taking the tuple returned by localtime() as parameter.
sleep()To stop the code execution for the given interval of time.
strptime()To get a tuple with all 9 time attributes.
gtime()To get struct_time which contains 9 time attributes.
mktime()To get seconds in floating point since epoch.
strftime()To get time in a specified format.

Python Calendar Module:

Python Calendar module contains various built in functions and statements to deal with all type of calendar related operations in the python code.

FUNCTIONUSES
prcal()To print whole calendar of the year.
firstweekday()To get the first week day.
isleap()To get a True value in case given year is leap else false.
monthcalendar()To get the given month with each week in a single list.
leapdays()To get the number of leap days between two years.
prmonth()To print the given month of the given year.

Example:

import calendar
year = input("Enter year to view: ")
month = input("Enter month to view: ")
print(calendar.month(year,month))

Continue Reading

Previous: What is an exception handler in Python
Next: What is Data Statistics And Analysis With Java And Python

Related Stories

What is Data Statistics And Analysis With Java And Python
9 min read
  • Learn Python

What is Data Statistics And Analysis With Java And Python

December 7, 2022
What is an exception handler in Python
2 min read
  • Learn Python

What is an exception handler in Python

December 7, 2022
What is python modules
2 min read
  • Learn Python

What is python modules

December 7, 2022

This AD Will support Us

Support Us

Coding Ustad LTD Support
Coding Ustad LTD Support

Coding Ustad LTD

Coding Ustad LTD
Coding Ustad LTD

Recent Posts

  • How to Install Node.js and npm on CentOS 7
  • How to Install Node.js and npm on CentOS 7
  • How to Install CentOS Web Panel (CWP) on CentOS 7
  • The Power of Marketing in Real Estate: A Guide to Boost Your Business
  • Vehicle Verification in Pakistan

Get free Hosting

Hostens.com - A home for your website

You may have missed

How to Install Node.js and npm on CentOS 7
4 min read
  • Coding Ustad LTD
  • Education for Everyone

How to Install Node.js and npm on CentOS 7

May 3, 2023
How to Install Node.js and npm on CentOS 7
4 min read
  • Coding Ustad LTD
  • Education for Everyone

How to Install Node.js and npm on CentOS 7

May 2, 2023
How to Install CentOS Web Panel (CWP) on CentOS 7
3 min read
  • Coding Ustad LTD
  • Education for Everyone

How to Install CentOS Web Panel (CWP) on CentOS 7

May 2, 2023
The Power of Marketing in Real Estate: A Guide to Boost Your Business https://thaikadar.com/secureinvestment/
2 min read
  • Article By Spoke Right
  • Blog By Spoke Right
  • Circular Byte Private Limited

The Power of Marketing in Real Estate: A Guide to Boost Your Business

January 30, 2023
  • Home
  • Our Services
  • Free Education
  • Spoke Right News
  • Earn Online
  • Classic Games by Spoke Right
  • Contact Us
Copyright © All rights reserved. | MoreNews by AF themes.