What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Request] seconds_since function

[Request] seconds_since function
Author: Message:
Fox-NL
New Member
*


Posts: 7
35 / Male / –
Joined: Oct 2005
O.P. [Request] seconds_since function
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);
}

This post was edited on 07-04-2006 at 04:28 PM by Fox-NL.
07-04-2006 10:49 AM
Profile PM Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
36 / Male / Flag
Joined: Mar 2004
RE: [Request] seconds_since function
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
[Image: dt2.0v2.png]      Happy Birthday, WDZ
07-04-2006 10:52 AM
Profile PM Web Find Quote Report
Fox-NL
New Member
*


Posts: 7
35 / Male / –
Joined: Oct 2005
O.P. RE: [Request] seconds_since function
errhhh what?
07-04-2006 11:05 AM
Profile PM Find Quote Report
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
Joined: Jul 2006
RE: [Request] seconds_since function
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;
07-04-2006 11:14 AM
Profile E-Mail PM Find Quote Report
Fox-NL
New Member
*


Posts: 7
35 / Male / –
Joined: Oct 2005
O.P. RE: [Request] seconds_since function
Thanks!
07-04-2006 11:21 AM
Profile PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: [Request] seconds_since 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);
}
07-04-2006 11:23 AM
Profile E-Mail PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: [Request] seconds_since function
does it calculate leap years?
07-04-2006 04:12 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On