Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting current date from clock

I am doing this

 boost::gregorian::date current_date(boost::date_time::day_clock::local_day());

and I get the following error

‘template<class date_type> class boost::date_time::day_clock’ used without template parameters  

Anything that I have to do different ?

reference http://www.boost.org/doc/libs/1_47_0/doc/html/date_time/gregorian.html#date_construct_from_clock

like image 416
HelloWorld_Always Avatar asked Apr 25 '12 02:04

HelloWorld_Always


People also ask

How can I get current date and time?

DateTimeFormatter. The LocalDateTime. now() method returns the instance of LocalDateTime class. If we print the instance of LocalDateTime class, it prints the current date and time.

How do I get the current date in Java 8?

You can get the time from the LocaldateTime object using the toLocalTime() method. Therefore, another way to get the current time is to retrieve the current LocaldateTime object using the of() method of the same class. From this object get the time using the toLocalTime() method.

How do I find the current date on LocalDate?

now() now() method of a LocalDate class used to obtain the current date from the system clock in the default time-zone. This method will return LocalDate based on system clock with default time-zone to obtain the current date.


1 Answers

You're using the wrong day_clock – use this instead:

boost::gregorian::date current_date(boost::gregorian::day_clock::local_day());

day_clock in boost::date_time is a generic interface (template in this case) meant to be used with an externally supplied 'date' type, and you're not supplying that type. day_clock in boost::gregorian is a typedef of said interface using boost::gregorian::date as the supplied 'date' type.

like image 102
ildjarn Avatar answered Sep 28 '22 11:09

ildjarn