我正在开发区域新闻应用程序。
如果您在巴黎,您所在的时区是Europe/Paris
,那么读者将获得离他们最近的新闻。我们每天早上9点发布新闻。
我们要允许before 9am
发布
如何检查9am Europe/Paris
中new Date()
是JavaScript
之后还是等于class foo:
def __init__(self,length):
self.length=length
# length
@property
def length(self):
return self._length
@length.setter
def length(self, val):
# do some checks here (e.g. for units, etc.) (same as in the class below)
self._length = val
class bar:
def __init__(self,width):
self.width=width
# width
@property
def width(self):
return self._width
@width.setter
def width(self, val):
# do some checks here (e.g. for units, etc.)(same as in the class above)
self._width = val
(无论客户区域是什么)?
答案 0 :(得分:0)
在处理多个时区时。您应该始终以UTC(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours)进行比较。这个想法是
var parisTime = new Date('March 20, 2020 09:00:00 GMT+01:00');
var parisInUTC = parisTime.getUTCHours();
var ukTime = new Date();
var ukInUTC = ukTime.getUTCHours();
console.log(parisTime);
console.log(parisInUTC);
console.log(ukTime);
console.log(ukInUTC);
console.log(ukInUTC < parisInUTC);
答案 1 :(得分:0)
您可以使用moment-timezone
moment.tz("09:00","HH:mm","Europe/Paris").isSameOrAfter(new Date())