Python | time.time_ns() method Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 2 Likes Like Report Time module in Python provides various time-related functions. This module comes under Python’s standard utility modules. time.time_ns() method of Time module is used to get the time in nanoseconds since the epoch. To get the time in seconds since the epoch, we can use time.time() method. The epoch is the point where the time starts and is platform dependent. On Windows and most Unix systems, the epoch is January 1, 1970, 00:00:00 (UTC) and leap seconds are not counted towards the time in seconds since the epoch. To check what the epoch is on a given platform we can use time.gmtime(0). Note: time.time_ns() method is new in Python version 3.7 Syntax: time.time_ns() Parameter: No parameter is required. Return type: This method returns an integer value which represents the time in nanoseconds since the epoch. Code: Use of time.time_ns() method Python3 # Python program to explain time.time_ns() method # importing time module import time # Get the epoch obj = time.gmtime(0) epoch = time.asctime(obj) print("epoch is:", epoch) # Get the time in seconds # since the epoch # using time.time() method time_sec = time.time() # Get the time in nanoseconds # since the epoch # using time.time_ns() method time_nanosec = time.time_ns() # Print the time # in seconds since the epoch print("Time in seconds since the epoch:", time_sec) # Print the time # in nanoseconds since the epoch print("Time in nanoseconds since the epoch:", time_nanosec) Output: epoch is: Thu Jan 1 00:00:00 1970 Time in seconds since the epoch: 1567451658.4676464 Time in nanoseconds since the epoch: 1567451658467647709 References: https://docs.python.org/3/library/time.html#time.time_ns Create Quiz Comment I ihritik Follow 2 Improve I ihritik Follow 2 Improve Article Tags : Python python-utility Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 4 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 3 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 3 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 4 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 3 min read StatsModel Library - Tutorial 3 min read Learning Model Building in Scikit-learn 6 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 5 min read Build a REST API using Flask - Python 3 min read Building a Simple API with Django REST Framework 3 min read Python PracticePython Quiz 1 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like