" Frank" <fr***@a-znet.comwrote in message
news:eH**************@TK2MSFTNGP02.phx.gbl...
I'll look at that. I did tried tm once but if I remember I got 2 for
example rather than March.
Maybe strftime was what I missed.
In your prior post you cautioned about rounding. Thanks for that. I got 0
when I expected 1 until I remember your caution.
Wasn't my post actually, but...
Define what you mean by "number of days since then". If the saved time is
11:59 PM on Feb 1, and current system time is 12:03 AM on Feb 2, the delay
is only 4 minutes, but midnight passed... so do you count that as a day?
Rounding won't really help you there.
If you mean calendar days, then you may want to convert your time_t to a tm
using localtime, zero the hour/minute/second fields, use mkgmtime to go back
to time_t, then difftime and divide by (24*60*60). In that way you will
count days elapsed since the beginning of the day in which the saved time
occurred.
>
thanks
"Ben Voigt" <rb*@nospam.nospamwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
>>
" Frank" <fr***@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>Thanks
Actually I thought of that after I posted. That question was an after
thought - without too much thought.
The main reason for posting is that I wanted to display a saved date,
without the time, and it seems there must be an easier way that what I
was doing.
First gmtime or localtime to get a struct tm, then strftime with a format
string of your choice.
>>>
Thanks a lot
"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:eo**********@ss408.t-com.hr...
" Frank" <fr***@a-znet.comwrote in message
news:ei**************@TK2MSFTNGP06.phx.gbl.. .
>I have a time saved in a time_t variable.
>
I'd like to be able to display the number of days since then but can't
find anything built-in that will help.
I believe dividing the number by (60*60*24) might give you the number
of days (depends on what exactly you have in that variable). Be careful
about how the result is rounded, though.
Failing that I'd like to display the date (only the date) that
corresponds to the saved time_t variable.
--
"It is easy in the world to live after the world's opinion; it easy in
solitude to live after our own; but the great man is he who in the
midst of the crowd keeps with perfect sweetness the independence of
solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/