Monday, July 8, 2019

Time formats and calendar

Script

#!/usr/local/bin/python3.5

import time
import calendar

ticker = time.time()
localtime = time.localtime(time.time())
localtimestamp = time.asctime(time.localtime(time.time()))
cally = calendar.month(2017, 2)

print()
print("The number of ticks since 12:00 a.m. on 1st January 1970:   ", ticker)
print()
print("The local current time is:  ", localtime)
print()
print("Local time is:  ", localtimestamp)
print()
print("This month's calendar:  ", cally)
print()


Execution

The number of ticks since 12:00 a.m. on 1st January 1970:    1488056409.2489665

The local current time is:   time.struct_time(tm_year=2017, tm_mon=2, tm_mday=25, tm_hour=13, tm_min=0, tm_sec=9, tm_wday=5, tm_yday=56, tm_isdst=0)

Local time is:   Sat Feb 25 13:00:09 2017

This month's calendar:      February 2017
Mo Tu We Th Fr Sa Su
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28






No comments:

Post a Comment