Showing posts with label time. Show all posts
Showing posts with label time. Show all posts

Sunday, March 11, 2018

Time asctime() Method


Time asctime() Method in Python 3


The method asctime() converts a tuple or struct_time representing a time as returned by gmtime() or localtime() to a 24-character string of the following form: 'Sun Mar 11 10:21:25 2018'.

Syntax
time.asctime([t]))

Parameters
t - This is a tuple of 9 elements or struct_time representing a time as returned by gmtime() or localtime() function.


Return Value
This method returns 24-character string of the following form: ' Sun Mar 11
10:21:25 2018'.

Example
#!/usr/bin/python3
import time
t = time.localtime()
print ("asctime : ",time.asctime(t))

When we run the above program, it produces the following result
asctime: Sun Mar 11 10:24:04 2018

Time altzone() Method


Time altzone() Method in Python 3


The method altzone() is the attribute of the time module. This returns the offset of the local DST timezone, in seconds west of UTC, if one is defined. This is negative if the local DST timezone is east of UTC (as in Western Europe, including the UK). Only use this if daylight is nonzero.

Syntax
time.altzone


Return Value
This method returns the offset of the local DST timezone, in seconds west of UTC, if one is defined.

Example

#!/usr/bin/python3
import time
print ("time.altzone : ", time.altzone)

When we run the above program, it produces the following result

time.altzone : -23400