Created
December 13, 2017 07:35
-
-
Save suncle1993/b1847ded921275b4ca259e111e56346b to your computer and use it in GitHub Desktop.
1、获取当天0点的时间戳 2、获取指定时间戳所在天0点的时间戳
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import re | |
import datetime | |
import os | |
import time | |
def getTimeOClockOfToday(): | |
t = time.localtime(time.time()) | |
time1 = time.mktime(time.strptime(time.strftime('%Y-%m-%d 00:00:00', t),'%Y-%m-%d %H:%M:%S')) | |
return int(time1) | |
def getTimeOClock(timestamp): | |
t = time.localtime(timestamp) | |
time1 = time.mktime(time.strptime(time.strftime('%Y-%m-%d 00:00:00', t),'%Y-%m-%d %H:%M:%S')) | |
return int(time1) | |
print(getTimeOClockOfToday()) | |
print(1512445645- getTimeOClock(1512445645)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment