On Aug 19, 10:42 am, korean_dave <[EMAIL PROTECTED]> wrote: > import datetime > > def main(): > timenow = datetime.datetime.now() > print(str(timenow.hour)) > > if __name__ == "__main__": > main() > > If the time was, say, 2pm, how can I make output of timenow.hour "14" > instead of "2"? > > Thanks. > -Dave
Use the strftime() method to convert the time. Something like this: print timenow.strftime('%H') See also: http://docs.python.org/lib/module-time.html Mike -- http://mail.python.org/mailman/listinfo/python-list