简体   繁体   English

从 servicenow 中的当前日期时间获取上周开始日期

[英]get last week start date from current date time in servicenow

As per my requirement if I pass the date-time then, How I can find which date is present on last week?根据我的要求,如果我通过了日期时间,我如何才能找到上周出现的日期?

Eg例如

var date1 = new GlideDateTime('2021-10-06 09:00:24');
var date2 = new GlideDateTime('2021-10-12 09:00:37');

Output:-输出:-

date 1 is present on last week.

You could use this function comparing the numbers of the weeks :您可以使用此函数比较周数:

function isLastWeek(gdt){
    return gdt.getWeekOfYearLocalTime() === new GlideDateTime().addWeeksLocalTime(-1).getWeekOfYearLocalTime();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM