• Profile
  • Resume
  • Portfolio
  • Blog
Avatar

Nelson Silva

A human. Being. Coffee lover.

Blog

I Write My Thoughts Here

Date and Time in Python

October 19, 2021 Python

In this post, you will learn how to work with the date and time so that you can use that same knowledge and thus evolve.

calendar(year) Returns a calendar of a certain year in read-only format
month(year, month) Returns the chosen month of a certain year in reading format
time() Returns the current system time in ticks since midnight on January 1, 1970
localtime(time()) Returns the current date and time in structured format
asctime(localtime(time())) Returns the current date and time in read format
# from calendar import *
from time import *

# print(calendar(2021))
# print(month(2021, 8))
print(time()) # 1628197388.7380881
print(localtime(time())) # time.struct_time(tm_year=2021, tm_mon=8, tm_mday=5, tm_hour=22, tm_min=3, tm_sec=8, tm_wday=3, tm_yday=217, tm_isdst=1)
print(asctime(localtime(time()))) # Thu Aug 5 22:03:08 2021

Don’t forget to watch the video and you can always read this post in Portuguese.

Happy coding!

Previous Next

Categories

  • Announcements
  • Python
  • C#
  • Java
  • Go

Latest Posts

  • for Loop in Go
    May 5, 2022
  • Switch in Go
    May 4, 2022
  • Comparison Operators in Go
    May 3, 2022
+351913416022
contact@nelsonsilvadev.com
Porto, Portugal
Nelson Silva © 2022 All Rights Reserved