Time Handling in Python

1. What is Tick?

2. What is Epoch?

3. What is Daylight Savings Time (DST)?

4. What is Time Tuple?

5. Getting current time:

6. Getting formatted time:

7. Getting calendar for a month:

8. Methods in Python Time Module:

  • %a — abbreviated day of week
  • %A — full day of week
  • %b — abbreviated name of month
  • %B — full name of month
  • %c — preferred date and time representation
  • %C — century number (the year divided by 100; range 00 to 99)
  • %d — day of month (1 to 31)
  • %D — the same as %m/%d/%y
  • %e — day of month (1 to 31)
  • %g — like %G, but without the century
  • %G — 4-digit year corresponding to the ISO week number (ref. %V).
  • %h — same as %b
  • %H — hour; using a 24-hr clock (0 to 23)
  • %I — hour; using a 12-hr clock (1 to 12)
  • %j — day of year (1 to 366)
  • %m — month (1 to 12)
  • %M — minute
  • %n — newline character
  • %p — AM/PM according to given time value
  • %r — time in AM/PM representation
  • %R — time in 24-hr representation
  • %S — second
  • %t — tab
  • %T — current time; equal to %H:%M:%S
  • %u — day of week as a number (1 to 7); Monday=1
  • %U — week of year, beginning with the first Sunday as the first day of the first week
  • %V — The ISO 8601 week of year (1 to 53); week 1 is the first with at least 4 days in the current year, and with Monday as the first day of the week
  • %W — week of year; beginning with the first Monday as the first day of the first week
  • %w — day of week as a decimal; Sunday=0
  • %x — the preferred date representation without the time
  • %X — the preferred time representation without the date
  • %y — year without century (00 to 99)
  • %Y — year including century
  • %Z or %z — time zone/name/abbreviation
  • %% — a % character

9. Attributes of the Time Module

References:

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Balancing Team Communication and Action with Twist and Todoist

Constructors of Flutter Widgets

Let’s do a .net core experiment

CONSISTENCY

Are hackathons really that great?

Simple Nested API Using Django Rest Framework

CodeJavi Attempt #2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abiakshar

Abiakshar

More from Medium

Polymorphism in Python

Object-oriented Python

Polymorphism in Python

Python Unit Testing