比较 ActionScript 中的两个日期值 - 可以比较全天值吗?

发布于 2024-12-03 06:14:35 字数 564 浏览 2 评论 0原文

我需要能够比较 ActionScript 中两个日期之间的整天数,这可能吗?

我想测试一个日期是否在今天之后 7 天或更短的时间内,如果是,则为一天或更短的时间(如果在今天之前,这也算在内)。

我采取的解决方法是使用日期字段的 .time 部分:

// Get the diffence between the current date and the due date
var dateDiff:Date = new Date();
dateDiff.setTime (dueDate.time - currentDate.time);
if (dateDiff.time < ( 1 * 24 * 60 * 60 * 1000 ))
    return "Date is within 1 day");
else if (dateDiff.time < ( 7 * 24 * 60 * 60 * 1000 ))
    return "Date is within 7 days");

正如我所说 - 这只是一种解决方法,我想要一个永久的解决方案来允许我检查两个日期之间的整天数。这可能吗? 谢谢

I need to be able to compare the number of whole days between two dates in ActionScript, is this possible?

I'd like to test if one date is 7 days or less after today, and if so is it one day or less (if it's before today this also counts).

The workaround I have in place is using the .time part of the date field:

// Get the diffence between the current date and the due date
var dateDiff:Date = new Date();
dateDiff.setTime (dueDate.time - currentDate.time);
if (dateDiff.time < ( 1 * 24 * 60 * 60 * 1000 ))
    return "Date is within 1 day");
else if (dateDiff.time < ( 7 * 24 * 60 * 60 * 1000 ))
    return "Date is within 7 days");

As I say - this is only a workaround, I'd like a permanent solution to allow me to check the number of whole days between 2 dates. Is this possible?
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

救赎№ 2024-12-10 06:14:35
var daysDifference:Number = Math.floor((dueDate.time-currentDate.time)/(1000*60*60*24));
if (daysDifference < 2)
   return "Date is within 1 day";
else if (daysDifference < 8)
   return "Date is within 7 days";
var daysDifference:Number = Math.floor((dueDate.time-currentDate.time)/(1000*60*60*24));
if (daysDifference < 2)
   return "Date is within 1 day";
else if (daysDifference < 8)
   return "Date is within 7 days";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文