-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCur_date.py
More file actions
96 lines (72 loc) · 1.96 KB
/
Cur_date.py
File metadata and controls
96 lines (72 loc) · 1.96 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import datetime
# from datetime import datetime,
# getting current date and time
'''
d = datetime.datetime.today()
print('Current date and time: ', d)
# getting current year
print('Current year: ', d.year)
#getting current month
print('Current month: ', d.month)
#getting current day
print('Current day: ', d.day)
# getting current hour
print('Current hour: ', d.hour)
# getting current minutes
print('Current minutes: ', d.minute)
# getting current Seconds
print('Current seconds: ', d.second)
# getting current microsecond
print('Current micro seconds: ', d.microsecond)
'''
def main():
date = getCurDate()
print "DATE=====" , date
print "Prev Day Date = " , getPrevDayDate()
print "Day = ", getDay()
print "Abb month = ",getAbbMon()
print "Cur Date = ", getCurDate()
print "StrfTime = ", strfTime(), type(strfTime())
now = datetime.datetime.now()
print now
print "=============="
print getCurDate_dashed()
def strfTime():
now = datetime.datetime.now()
return now.strftime('%Y-%m-%d')
def getPrevDayDate():
yesterday = datetime.datetime.today() - datetime.timedelta(days = 1)
# yesterday.strftime('%m%d%y')
day = yesterday.day
day = str(0)+str(day) if day<10 else str(day)
print "YESTER = ",day
return day
def getDay():
d = datetime.datetime.today()
day = d.day
day = str(0)+str(day) if day<10 else str(day)
return day
def getAbbMon():
d = datetime.datetime.now()
mon = d.strftime("%b")
return mon.lower()
def getCurDate():
d = datetime.datetime.today()
year = d.year
month = d.month
month = str(0)+str(month) if month<10 else str(month)
day = d.day
day = str(0)+str(day) if day<10 else str(day)
date = (day)+(month)+str(year)
return date
def getCurDate_dashed():
d = datetime.datetime.today()
year = d.year
month = d.month
month = str(0)+str(month) if month<10 else str(month)
day = d.day
day = str(0)+str(day) if day<10 else str(day)
date = (day)+"-"+(month)+"-"+str(year)
return date
if __name__ == "__main__":
main()