Shoutbox

[Request] seconds_since function - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Request] seconds_since function (/showthread.php?tid=62499)

[Request] seconds_since function by Fox-NL on 07-04-2006 at 10:49 AM

Hello!

Can somebody make me a seconds_since function?
The parameters should be day, month and year, something like: seconds_since(day,month,year);... it will return the number of seconds ellapsed since the chosen data


It will be used something like this:

Messenger.MyPersonalMessage = "Today I life "+seconds_since(24,03,1990)+" seconds!";

or:

Messenger.MyPersonalMessage = "I'm 16 for "+seconds_since(24,03,2006)+" seconds!";

Thanks in advance


Got it! Here's the function:

code:
function seconds_since(day, month, year) {
    var myDate=new Date();
    myDate.setFullYear(year,month - 1,day);
    var myDate2=new Date();
    return Math.round((myDate2.getTime() - myDate.getTime()) / 1000);
}

RE: [Request] seconds_since function by -dt- on 07-04-2006 at 10:52 AM

Create two javascript Date objects , and with one pass the date to it then minus them :P

http://www.w3schools.com/js/js_obj_date.asp


RE: [Request] seconds_since function by Fox-NL on 07-04-2006 at 11:05 AM

errhhh what?


RE: [Request] seconds_since function by foaly on 07-04-2006 at 11:14 AM

try something like

oninitialize
var actDate=new Date();

and then in the pm update function:

var nowDate = new Date();
var time = (actDate=nowDate);

Messenger.MyPersonalMessage = "I'm 16 for "+time;


RE: [Request] seconds_since function by Fox-NL on 07-04-2006 at 11:21 AM

Thanks!


RE: [Request] seconds_since function by J-Thread on 07-04-2006 at 11:23 AM

code:
function seconds_since(day, month, year) {
var myDate=new Date();
myDate.setFullYear(year,month - 1,day);
var myDate2=new Date();
return Math.round((myDate2.getTime() - myDate.getTime()) / 1000);
}

RE: [Request] seconds_since function by deAd on 07-04-2006 at 04:12 PM

does it calculate leap years?