0

我制作了贯穿包中元素的 jscript,现在我需要添加 element.created 与今天的比较。我怎样才能做到这一点?

4

1 回答 1

0

请参考以下代码并进行相应修改

// get the date from the element
var dateCreated = new Date(theElement.Created);

// remove the hours, minutes, seconds, miliseconds
dateCreated.setHours(0,0,0,0);

// create the date object to compare
// input parameter is yyyy, mm, dd
// please note that the mm starts from 0 for January
var dateToCompare = new Date(2013, 0, 13);

// sample usage
if (dateCreated > dateToCompare)
{
    Session.Output("Creation date is newer");
}
else if (dateCreated < dateToCompare)
{
    Session.Output("Creation date is older");
}
else
{
    Session.Output("Creation date match");
}
于 2013-08-13T03:53:43.777 回答