Dejwi
Dejwi

Reputation: 4487

C++11 number of days since date

I need to store date in flat file. Is there any simple metod to get number of days since particular date (for example since 1 AD) using standard libary in C++11? The only one I know is to:

Can I perform it easier?

Upvotes: 3

Views: 505

Answers (1)

John Zwinck
John Zwinck

Reputation: 249153

What you said sounds reasonable to start with. You can convert the struct tm to time_t using mktime. Note that mktime interprets its input as local time according to the system/environment settings, and there is no UTC counterpart that's as widely available without relying on "extra" libraries, but maybe that's not a problem for you.

Upvotes: 2

Related Questions