Note the problem:
The time format is returned in seconds and milliseconds;
//Calculate the distance between the creation time and the current time
function Gettimespan (origtime) {
if (Origtime < 10000000000)
origtime = origtime * 1000//second is 10 bits, if is less than 11 bit is not milliseconds, to add three bits into milliseconds
var d = new Date ();
var span = D.gettime ()-origtime;
var days = Math.floor (span/(24 * 3600 * 1000));
if (Days > 0) {
var n = new Date (origtime);
var result = N.getfullyear () + "-" + (N.getmonth () + 1) + "-" + n.getdate ();
return result;
}
else {
var leave = Math.floor (span% (24 * 3600 * 1000));
Hours = Math.floor (Leave/(3600 * 1000));
if (Hours > 0) {
Return hours + "hours ago";
}
else {
var minutes = Math.floor (leave% (3600 * 1000));
minutes = Math.floor (minutes/(60 * 1000));
if (minutes > 0) {
Return minutes + "minutes ago";
}
else {
return "just";
}
}
}
}
//Calculate the distance from the current time to the end time
function Timecountdown (origtime) {
if (Origtime < 10000000000)
Origtime = origtime * 1000
var d = new Date ();
var span = Origtime-d.gettime ();
if (span<=0) {
return "closed";
}
var days = Math.floor (span/(24 * 3600 * 1000));
if (Days > 0) {
Return "remaining" + days + "Day End";
}
else {
var leave = Math.floor (span% (24 * 3600 * 1000));
Hours = Math.floor (Leave/(3600 * 1000));
if (Hours > 0) {
Return "remaining" + hours + "hour End";
}
else {
var minutes = Math.floor (leave% (3600 * 1000));
minutes = Math.floor (minutes/(60 * 1000));
if (minutes > 0) {
Return "remaining" + minutes + "minute end";
}
else {
Return "Coming to an end";
}
}
}
}
//long-Time conversion to formatted datetime
function Convertlongtodate (origtime)
{
if (Origtime < 10000000000)
Origtime = origtime * 1000
var d = new Date ();
var span = D.gettime ()-origtime;
var days = Math.floor (span/(24 * 3600 * 1000));
var n = new Date (origtime);
if (Days > 0) {
var result = N.getfullyear () + "-" + (N.getmonth () + 1) + "-" + n.getdate ();
return result;
}
else {
var result = N.gethours () + ":" + n.getminutes ();
return result;
}
}
Time the activity was created