K. Barresi
K. Barresi

Reputation: 1315

Visual C++: Compare Dates

So I'm trying to find out if the current date on a Windows machine is after a hardcoded date. How would I go about doing this without using Boost or ATL? I'm using Visual Studio 2010 C++

Upvotes: 0

Views: 561

Answers (2)

Ben Voigt
Ben Voigt

Reputation: 283624

You can use the OS-provided GetSystemTime or GetLocalTime functions, which return date components, or GetSystemTimeAsFileTime, which returns the number of 100-nanosecond intervals that have elapsed since 12:00 A.M. January 1, 1601. No additional support libraries needed.

Upvotes: 1

user1342784
user1342784

Reputation:

The platform independent way to get the current date in C++ is time(NULL), which returns seconds since Jan 1, 1970. You can use other routines in ctime to either turn that into a string, pull out day/month/year/etc.

Upvotes: 1

Related Questions