28.10.2021 Views

Python Tutorial ( PDFDrive )

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Parameters

• sec -- These are the number of seconds to be converted into string representation.

Return Value

This method does not return any value.

Example

The following example shows the usage of ctime() method.

#!/usr/bin/python

import time

print "time.ctime() : %s" % time.ctime()

Let us compile and run the above program, this will produce the following result:

time.ctime() : Tue Feb 17 10:00:18 2009

time.gmtime([secs])

Description

The method gmtime() converts a time expressed in seconds since the epoch to a struct_time in UTC in which the

dst flag is always zero. If secs is not provided or None, the current time as returned by time() is used.

Syntax

Following is the syntax for gmtime() method:

time.gmtime([ sec ])

Parameters

• sec -- These are the number of seconds to be converted into structure struct_time representation.

Return Value

This method does not return any value.

Example

The following example shows the usage of gmtime() method.

#!/usr/bin/python

import time

print "time.gmtime() : %s" % time.gmtime()

Let us compile and run the above program, this will produce the following result:

time.gmtime() : time.struct_time(tm_year=2013, tm_mon=4, tm_mday=28, tm_hour=12,

tm_min=29, tm_sec=48, tm_wday=6, tm_yday=118, tm_isdst=0)

TUTORIALS POINT

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!