Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a string to a date in C++

Tags:

I know this may be simple but being C++ I doubt it will be. How do I convert a string in the form 01/01/2008 to a date so I can manipulate it? I am happy to break the string into the day month year constituents. Also happy if solution is Windows only.

like image 688
Ubervan Avatar asked Nov 21 '08 10:11

Ubervan


People also ask

How do I convert a string to a date?

Using strptime() , date and time in string format can be converted to datetime type. The first parameter is the string and the second is the date time format specifier. One advantage of converting to date format is one can select the month or date or time individually.

What is Strptime in C?

Description. The strptime() function converts the character string pointed to by buf to values that are stored in the tm structure pointed to by tm, using the format specified by format. The format contains zero or more directives.

Can we convert date to string?

We can convert Date to String in java using format() method of java. text. DateFormat class.


1 Answers

#include <time.h> char *strptime(const char *buf, const char *format, struct tm *tm); 
like image 89
kenny Avatar answered Oct 26 '22 18:10

kenny