AWS lambda的差异应为3,获得19097
然后最终将其汇合到最近的数字,因此12.8天为13。
我有一个AWS lambda函数,其中一部分计算上一个日期和今天日期之间的差异,调整为代表天数, 任何人都知道lambda是否具有表示date()
函数的某些不同方法,因为在登录过程中的各个步骤后,我会返回一些怪异的值,因此我的函数不起作用。这是一些代码:
const today = new Date();
let item = {lasetReceiptCreated: '2022-04-11T20:00:22.549Z'};
let lastReceiptCreated = new Date(item.lasetReceiptCreated);
let dateDiff = today.getTime(); - lastReceiptCreated.getTime();
let diffInDays = Math.round(dateDiff / (1000 * 3600 * 24));
console.log('SkipDayCalc: ','\ndiff: ',diffInDays,'\ntoday.getTime: ',today.getTime(),'\nreceipt.getTime(): ',lastReceiptCreated.getTime());
结果日志显示了这一点:
SkipDayCalc:
diff: 19097
today.getTime: 1649963123100
receipt.getTime(): 1649707222549
那么为什么我的diffindays
值返回为19097?当我在节点沙盒中运行时,我将获得具有相同代码的正确值。
I have a AWS lambda function, part of which computes the difference between a previous date and todays date, adjusts to represent as days and then finally rounds this to the nearest number, so 12.8 days for example will be 13.
I'm wondering if anyone knows if Lambda has some different way of representing Date()
functions, because upon logging the results of various steps in the process I'm getting some weird values returned and hence my function isn't working. Here's some code:
const today = new Date();
let item = {lasetReceiptCreated: '2022-04-11T20:00:22.549Z'};
let lastReceiptCreated = new Date(item.lasetReceiptCreated);
let dateDiff = today.getTime(); - lastReceiptCreated.getTime();
let diffInDays = Math.round(dateDiff / (1000 * 3600 * 24));
console.log('SkipDayCalc: ','\ndiff: ',diffInDays,'\ntoday.getTime: ',today.getTime(),'\nreceipt.getTime(): ',lastReceiptCreated.getTime());
The resulting log shows this:
SkipDayCalc:
diff: 19097
today.getTime: 1649963123100
receipt.getTime(): 1649707222549
So why is my diffInDays
value returning as 19097? When I run in a node sandbox I'm getting the correct value with the same exact code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论