datetime.datetime.now() in military time

korean_dave davidreynon at gmail.com
Tue Aug 19 17:42:55 CEST 2008


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



More information about the Python-list mailing list