Link to home
Start Free TrialLog in
Avatar of RobertNZana
RobertNZanaFlag for United States of America

asked on

Showing time left

Given a future date/time variable (function input), how can I output how much time is left in this format...

"2 years, 3 months, 4 days, 11 hours, 20 minutes and 10 seconds remaining."

To go 1 step further, I would like to have several boolean input variables for the function, like...
bShowYears as boolean, bShowMonths as boolean, bShowDays as boolean

So if they turn bShowYears to false then the "months" would reflect this and the out put would be (using the same example)....

"27 months, 4 days, 11 hours, 20 minutes and 10 seconds remaining."

Please provide sample code in vb.net. Thanks
ASKER CERTIFIED SOLUTION
Avatar of MaximumIQ
MaximumIQ
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To make it work how you want you can make it only query the seconds difference and just use math to calculate the rest
Avatar of RobertNZana

ASKER

Can you please extend the example to show what you mean? Thanks.
Your code doesn't do what it should. I need it to break it down further. Can anyone assist please?

To simplify, given 2 date/times, return the time left between them in this format....

x years, x months, x weeks, x days, x hours, x minutes, x seconds

Thanks
Close but not really.