Import time,datetime from
datetime import timedelta
import sys
reload (SYS)
format= "%y-%m-%d%h:%m:%s "Now
= Datetime.datetime.now (). Replace (hour=0,minute=0,second=0)
Aday = Timedelta (days =-1)
enddate= Now+aday
Startdate=enddate.replace (day=1);
Print now.strftime (format) print enddate.strftime (format) print
startdate.strftime (format)
print int (Time.mktime (Time.strptime (enddate.strftime (format), '%y-%m-%d%h:%m:%s ')) *1000)
Print Time.strftime (Format,now)
(1) When using Python, it often involves the operation of time.
The most commonly used time module in Python.
Import time,datetime from
datetime import timedelta
import sys
reload (SYS)
Get current time
format= "%y-%m-%d%h:%m:%s"
Now=datetime.datetime.now ()//Current time
Print now
#2013-11-07 14:59:53.331000
Set year, month, day
Now.replace (year=2011,month=12,day=1,hour=0,minute=0,second=0)
Converts a date (now) to a string
Now.strftime (format)//mode 1
Get current time stamp
Print Time.time ();
1383807657.91
Convert a string to a date
Time.strptime (Format,now)//Mode 2
Converts a string to a timestamp
Time.mktime (Time.strptime (' 2012-03-28 06:53:40 ', '%y-%m-%d%h:%m:%s '))
Convert time stamp to date
Time.localtime (1317091800.0)
Time.strftime ('%y-%m-%d%h:%m:%s ', x)