[英]Moment.js timezones: Problem finding an item in array within date range
I have an array of programs. 我有一系列程序。 Each of which has start_date and end_date. 每个都有开始日期和结束日期。
I want to find the current running program in the array by checking my current date in the range of each program's start_date and end_date. 我想通过检查每个程序的start_date和end_date范围内的当前日期来在数组中找到当前正在运行的程序。
The problem is that the programs were added in a specific time zone, but the dates don't have the time zone info on them. 问题在于,程序是在特定时区添加的,但是日期上没有时区信息。
I have tried setting offsets by the time zones that the program is created. 我尝试通过程序创建的时区设置偏移量。 But it didn't help. 但这没有帮助。
const range = moment.range(moment(el.start_date), moment(el.end_date));
moment().within(range);
This works well in the timezone that the program was created. 在创建程序的时区中,此方法效果很好。
moment().utcOffset(240).within(range);
I tried to fix the problem like this, but it didn't help. 我试图解决此问题,但没有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.