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,


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

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


Python Recommendations:

C++ & C++11 Recommendations:

If you didn't find what you were looking, then do suggest us in the comments below. We will be more than happy to add that.

Subscribe with us to join 1500+ Python & C++ developers, to get more Tips &  Tutorials like this.