mIRC Home    About    Download    Register    News    Help

Print Thread
H
Hub
Hub
H
Anyone can help me out with this one?

I try to calculate the time between two dates in years, weeks, days, hours minutes and seconds in mirc scripting, and I have stumbled over problems every single time I did, now I was hoping if somebody could help me with this one

something like this (I used a php script for that)
From 24 oktober 1999, 13:21:54
To 1 september 2005, 13:34:02

Or 5 years, 10 months, 8 days, 12 minutes, 8 seconds

thanks in forward
-Hub

Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
This is more a scripting question, and it has been answered before. These threads are about this exact problem:
Countdown
Making $duration include months/years <- It's a long thread with a lot of fixes and further refinement, so read it all and use the latest versions of the respective scripts...

Joined: Jan 2003
Posts: 247
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 247
you can use $asctime() to convert your dates into UNIX Timestamp format (the same thing returned by $ctime), then substract them to get the difference and finally reconverting them to whatever output you want using duration. Only problem I see is that duration doesn't support years, so you may have to code your own version.

Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Yeah, there are a few threads on the topic of date differences. The script I did (in the second link Kelder gave) adds months and years accurately, so it could be used with the $ctime/$asctime method. I showed how to do that in yet another thread on the issue at one point...

Here's that other thread:
Date ranges

In that link, either look down to see either the example with the two $ctime(date)'s in it, or look in the following post that shows an alias example.

Both would, of course, need my $DateXpander script that the last post in the second link from Kelder above has links to.


Link Copied to Clipboard