Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I am a total newbie so please bear with me.

I have a page on our website that displays the LAST TIME a reading was taken. What I would like to show is the days & hours since that last reading.
eg: last reading was yesterday 12noon, time now is 10am so I want to display that it has been 22 hours since last reading.
Code at present to display the last reading is
]]>

Any help would be greatly appreciated.

Cheers,
Rob
Posted
Comments
Sandeep Mewara 28-Jun-10 1:49am    
Did you tried playing around with DateTime.Now?

1 solution

DateTime instances, such as that returned by DateTime.Now have a Subtract[^] method which returns an instance of TimeSpan. TimeSpan includes a number of properties, such as TotalMinutes which can be used for exactly the purpose you're after.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900