Python | time.clock_settime() method

time.clock_settime() method of Time module is used to set the time (in seconds) of the specified clock clk_id. Basically, clk_id is a integer value which represents the id of the clock.

Syntax: time.clock_settime(clk_id, seconds)

Parameters:
clk_id: A clk_id constant or an integer value representing clk_id of the clock.



Return type: This method does not return any value.

Code: Use of time.clock_settime() method

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program to explain time.clock_settime() method
  
# importing time module
import time
  
  
# clk_id for System-wide real-time clock
clk_id = time.CLOCK_REALTIME
  
  
# Get the current value of
# system-wide real-time clock (in seconds)
# using time.clock_gettime() method
t = time.clock_gettime(clk_id) 
  
print("Current value of system-wide real-time clock: % d seconds" % t)
  
# Set the new value of
# time (in seconds) for
# System-wide real-time clock
# using time.clock_settime() method
seconds = 10000000
time.clock_settime(clk_id, seconds)
  
print("\nTime  modified")
  
  
# Get the modified value of
# system-wide real-time clock (in seconds)
# using time.clock_gettime() method
t = time.clock_gettime(clk_id) 
print("\nCurrent value of system-wide real-time clock: % d seconds" % t)

chevron_right


Output:

Current value of system-wide real-time clock: 1568589568 seconds

Time  modified

Current value of system-wide real-time clock: 10000000 seconds

Reference: https://docs.python.org/3/library/time.html#time.clock_settime



My Personal Notes arrow_drop_up

self motivated and passionate programmer

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.