Python Time Function | TimeStamp | Time Milli Seconds Now

Python Time Function is used for getting the time. In python to use time function, you need to import time modules, no third party library required. The python time function returns the time in seconds floating-point number since the epoch, in UTC

Python Time Function | TimeStamp | Time Milli Seconds Now example


You have to import the time module to get time.

Note: no parameters are required, but in some cases you needed a format.

Python Time Function Example 

Output: Time : 1538973413.1055639
time.struct_time(tm_year=2018, tm_mon=10, tm_mday=8, tm_hour=10, tm_min=6, tm_sec=53, tm_wday=0, tm_yday=281, tm_isdst=0)
Mon Oct 8 10:06:53 2018

Python Time Function | TimeStamp | Time Milli Seconds Now example output

Get the Hour, Minutes and Seconds

Here is an example of getting, How to get an Hour, Minutes, and seconds in using python time function?

Output: Hour: 12
Minutes: 17
Seconds: 10

Get the Year, Month and Day

With Time function you can get the Year, Month, and Day.

Output: Year: 2018
Month: 10
Day: 8

Python time milliseconds 

To get a time in milliseconds you have to multiple in time object, like this example.

Output: Milliseconds 1538990568714

Do comment if you have any doubts and suggestions on this tutorial.

Note: This example (Project) is developed in PyCharm 2018.2 (Community Edition)
JRE: 1.8.0
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6

Python 3.7

All examples are in Python 3, so it may change its different from python 2 or upgraded versions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.