Skip to content

Commit bcdb8df

Browse files
committed
Create get_time
1 parent ea57ee5 commit bcdb8df

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

get_time

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
def GetCurWorldTimeSec():
2+
import time
3+
return time.time()
4+
5+
def GetCurTimeStr(time_zone = 0): ### Default is World Standard Time
6+
import time
7+
time_sec = time.time() + time_zone*3600
8+
time_str = time.strftime("%Y%m%d %X",time.gmtime(time_sec))
9+
time_str = "".join(time_str.split(":"))
10+
return time_str
11+
12+
def GetCurrentChinaTime():
13+
return GetCurTimeStr(8) ### Eastern eight zones
14+
15+
def GetCurrentWorldTime():
16+
return GetCurTimeStr()
17+
18+
print(GetCurrentChinaTime())
19+
print(GetCurrentWorldTime())

0 commit comments

Comments
 (0)