Python 1200 examples - [17] Summary of date and time operations

Related modules

  1. datetime module :

    • datetimeThe module provides classes for date and time.
    • dateClass: represents date (year, month, day).
    • timeClass: Represents time (hours, minutes, seconds, microseconds).
    • datetimeClass: Represents date and time.
  2. timedelta object :

    • timedeltaRepresents the difference between two dates or times.
    • It can be used as a representation of date intervals, or to represent the length of a period of time.
  3. strftime and strptime methods :

    • strftimeMethod used to datetimeformat an object into a string.
    • strptimeMethod for parsing date and time from string.
  4. Other common methods :

    • now(): Get the current date and time.
    • today(): Get the current date (without time part).
    • utcnow(): Gets the current Coordinated Universal Time (UTC) date and time.
  5. Time zone related content :

    • Python provides tools for handling time zones, including time

Guess you like

Origin blog.csdn.net/m0_47867638/article/details/135349043