import
time,datetime
# date to str
print
time.strftime(
"%Y-%m-%d %X"
, time.localtime())
#str to date
t
=
time.strptime(
"2009 - 08 - 08"
,
"%Y - %m - %d"
)
y,m,d
=
t[
0
:
3
]
print
datetime.datetime(y,m,d)
|
2015
-
05
-
13
10
:
43
:
07
2009
-
08
-
08
00
:
00
:
00
|
运行结果:
1377507480.0
2013-08-26 16:58:00