convert countdown to y d h m s
Convert a xt:countdown to years days hours minutes seconds
Example code
Show in textarea<!--parser:xtscript-->
# Convert countdown to years days hours minutes and seconds
function convert $t1
# seconds
var $s1=($t1/60)
var $s2=call floor $num=$s1
var $s3=($s1-$s2)
var $s4=call floor $num=(60*$s3)
var $s5=seconds
if $s4==1
var $s5=second
endif
# minutes
var $m1=($t1/60/60)
var $m2=call floor $num=$m1
var $m3=($m1-$m2)
var $m4=call floor $num=(60*$m3)
var $m5=minutes
if $m4==1
var $m5=minute
endif
# hours
var $h1=($t1/60/60/24)
var $h2=call floor $num=$h1
var $h3=($h1-$h2)
var $h4=call floor $num=(24*$h3)
var $h5=hours
if $h4==1
var $h5=hour
endif
# days
var $d1=($t1/60/60/24/365.25)
var $d2=call floor $num=$d1
var $d3=($d1-$d2)
var $d4=call floor $num=(365.242374*$d3)
var $d5=days
if $d4==1
var $d5=day
endif
# years
var $y1=call floor $num=$d1
var $y2=years
if $y1==1
var $y2=year
endif
# Return converted countdown
return $y1 $y2 $d4 $d5 $h4 $h5 $m4 $m5 $s4 $s5
endfunction
# Call conversion function
var $countdown=<xt:countdown format="seconds" from="now" to="2101-01-01"/>
call convert $t1=$countdown
<!--/parser:xtscript-->
Show in textarea Example output
Reload76 years 39 days 12 hours 12 minutes 23 seconds