獲取當(dāng)前時(shí)間戳
發(fā)展壯大離不開廣大客戶長(zhǎng)期以來(lái)的信賴與支持,我們將始終秉承“誠(chéng)信為本、服務(wù)至上”的服務(wù)理念,堅(jiān)持“二合一”的優(yōu)良服務(wù)模式,真誠(chéng)服務(wù)每家企業(yè),認(rèn)真做好每個(gè)細(xì)節(jié),不斷完善自我,成就企業(yè),實(shí)現(xiàn)共贏。行業(yè)涉及成都高空作業(yè)車租賃等,在成都網(wǎng)站建設(shè)、全網(wǎng)整合營(yíng)銷推廣、WAP手機(jī)網(wǎng)站、VI設(shè)計(jì)、軟件開發(fā)等項(xiàng)目上具有豐富的設(shè)計(jì)經(jīng)驗(yàn)。
time_now = int(time.time()) #時(shí)間戳
# 1529461333
import time
current_time=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
current_hour=time.strftime('%H',time.localtime(time.time()))
#輸出格式: '2018-06-20 10:20:19'
current_time=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
#在數(shù)據(jù)庫(kù)中,字段可以是varchar而不是datetime
a=1490931508
time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(a))
c='2017-03-31 11:38:28'
d=time.strptime(c,'%Y-%m-%d %H:%M:%S')
time.mktime(d)
from bson import json_util
import json
json.dumps(anObject, default=json_util.default)
json.loads(aJsonString, object_hook=json_util.object_hook)
方法一:
time1 = datetime.datetime.now()
time2 = datetime.datetime.now()
seconds = (time2 - time1).seconds
print 'seconds',seconds
方法二:
#先獲得時(shí)間數(shù)組格式的日期
oneDayAgo = (datetime.datetime.now() - datetime.timedelta(days = 1))
#minutes, days, months,
#轉(zhuǎn)換為時(shí)間戳:
timeStamp = int(time.mktime(oneDayAgo.timetuple()))
#轉(zhuǎn)換為其他字符串格式:
time1 = oneDayAgo.strftime("%Y-%m-%d %H:%M:%S")
time2 = host.update_time
if time2 > time1:
print "正常"
else:
print "未上報(bào)"