In this articlew we will discuss how to get Current Date & Time in C++ using Boost Date Time Library.

Boost Date Time Library provides a type,

to specify a particular time point. It includes a date and timestamp representing a specific time point.

For example,

Here timeObj represents a time point “2016/2/19 9:01:33.10”

It basically included a date and a time i.e.

Getting Current Time

We can also get the date, month, year, hours, minute & Seconds from the ptime object using its member functions i.e.

Getting the Current Time in UTC Timezone

Complete example is as follows,

Output:

To Compile the above code, use following command in linux,

g++ –std=c++11 example.cpp -lboost_date_time